|
 |
|
SQL เทียบ 3 ตารางได้ไหมครับโดยใช้ NOT IN เพื่อเทียบข้อมูลของ 3 ตาราง |
|
 |
|
|
 |
 |
|
ไม่เข้าใจความต้องการครับ คุณจะเอา tb3 มาเป็นตัวเปรียบเทียบ หรือจะเอามาเป็นส่วนหนึ่งของ row
|
 |
 |
 |
 |
Date :
2019-04-07 08:35:26 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
SELECT * FROM item WHERE Serialnumber NOT IN ( SELECT ID FROM content )
and ( select serealnumber FROM recoup ) "
บันทัดบน พอจะเข้าใจ แต่ สีแดง ไม่เข้าใจ
ลอง เขียน ผลลัพธ์ ที่ต้องการให้ดูหน่อยครับ
หรือ ลองทำ ทำความเข้าใจ ตรงนี้ก่อน
Code (SQL)
select tb1.id, tb1,tb1.nm
from table1 as tb1
where tb1.tb2_id not in (select id from table2)
union all
select tb3.id, tb3.nm from table3 as tb3
หรือ
Code (SQL)
select tb1.id, tb1,tb1.nm
from table1 as tb1
where tb1.tb2_id not in (select id from table2)
and tb1.id in (select id from table3)
โค๊ดตัวอย่างมันผิด เลยตีความไปได้หลายอย่าง เดาไม่ถูกหรอกครับ
|
 |
 |
 |
 |
Date :
2019-04-10 19:37:57 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|