문제

Let's say I have a table named "mytable01". When I want to have two instances of the table in the query I do this:

SELECT t1.column, t2.column
FROM mytable01 t1, mytable01 t2;

Now, there are times that I want two instances from the same nested SELECT. Is there a way to do it without having to write it two times?

올바른 솔루션이 없습니다

다른 팁

No! You want to do a self-join (joining the table with itself) you must to declare it each time. By the way try to avoid write queries in implicit format and use explicit join pattern like it:

select t1.column, t2.column
from table t1
join table t2 on t2.id = t1.parentid

btw again, you example missed the columns for the join and that ill force a cross join.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top