「サブクエリー+IN」、「LEFT JOIN」、「RIGHT JOIN」により
テーブルから同じ結果を抽出。

General Query (IN)

SELECT * FROM project WHERE project.id IN
(SELECT client.id FROM client)

LEFT JOIN

select B.PID,B.ID,B.NAME,B.START,B.END from client A
LEFT JOIN project B using(ID) /* or: ON A.ID = B.ID */
WHERE B.NAME IS NOT NULL;

RIGHT JOIN

select B.PID,B.ID,B.NAME,B.START,B.END from project B
RIGHT JOIN client A using(ID) /* or: ON A.ID = B.ID */
WHERE B.NAME IS NOT NULL;

right_join

Comments are closed.

Post Navigation