Answer the question
In order to leave comments, you need to log in
SQL: how to display 2 columns of the same name in one table, so that one column has names, and the other column has dependencies?
Good day Toaster, developed a database and faced the problem of how to extract data from it, in the desired presentation. I have a database running sqlite. The base has the following structure shown in the picture. Tell me how to display names from the items table in one column and display dependencies in the other using the deps and trades tables in the names view from the items table?
I tried to use the union operator with an alias of the name column from the items table, but the data from name is still displayed in one column.
Answer the question
In order to leave comments, you need to log in
SELECT
deps.itemid as itemid1, tradeid.itemid as itemid2
FROM
deps
LEFT JOIN
tradeid
ON
deps.tradeid = tradeid.id
SELECT
items1.name as name1, items2.name as name2
FROM
(предыдущий запрос) ids
LEFT JOIN items items1 ON items1.id = ids.itemid1
LEFT JOIN items items2 ON items2.id = ids.itemid2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question