Answer the question
In order to leave comments, you need to log in
How does this SQL query work?
Hello everybody.
A long time ago I wrote a request, now I remembered it and I want to finally understand how it works.
Let there be 3 tables, two are connected through one.
table A ( id1, text1)
table B (id2, text2)
table C (id1, id2)
The query itself
select
(select text1 from A where A.id1 = C.id1) as 'A',
(select text2 from B where B.id2= C.id2) as 'B'
from C;
Answer the question
In order to leave comments, you need to log in
the main query is table C. it is the number of records in it that will be displayed in the selection. and columns text1 and text2 are pulled out from subqueries to tables B and A. And those, in turn, will take values for searching from the main query, that is, from table C.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question