Answer the question
In order to leave comments, you need to log in
SQL query to get similar data from two tables?
Good day, I'm doing a small Pet-project and I'm having difficulties with designing a database and writing efficient SQL queries, I'll get straight to the point: I'm
using PostgreSQL, I have the following list of tables:
// Таблица с аккаунтами
Table accs {
id int [pk, increment]
}
// Таблица с магазинами
Table shops {
id int [pk, increment]
}
// Таблица с товарами аккаунтов
Table accs_products {
id int [pk, increment]
owner_acc_id int [ref: > accs.id]
name text
product_uniq_field_first text
}
// Таблица с товарами магазинов
Table shops_products {
id int [pk, increment]
owner_shop_id int [ref: > shops.id]
name text
product_uniq_field_second text
}
// Таблица с избранными аккаунтами для каждого аккаунта
Table favourite_accs_for_accs {
acc_id int [ref: > accs.id]
fav_acc_id int [ref: > accs.id]
}
// Таблица с избранными магазинами для каждого аккаунта
Table favourite_shops_for_accs {
acc_id int [ref: > accs.id]
fav_shop_id int [ref: > shops.id]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question