sql - MYSQL unselect query from second table -
hi have 2 table
table 1
id selection ------------------- 1 john 2 ely 3 marcus 4 steve 5 fritz 6 orly 7 carlo 8 lee
table 2
id selected ------------------- 1 john 3 marcus 4 steve 5 fritz 7 carlo
the return unselected rows. query output
id selection ------------------- 2 ely 6 orly 8 lee
use left join
join both table , t2.id null
remove common records
select t1.* table1 t1 left join table2 t2 on t1.id = t2.id t2.id null
output:
╔════╦═══════════╗ ║ id ║ selection ║ ╠════╬═══════════╣ ║ 2 ║ ely ║ ║ 6 ║ orly ║ ║ 8 ║ lee ║ ╚════╩═══════════╝
Comments
Post a Comment