• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

sql select query in table one, NOT in table 2

what would be the best way to do the following SQL code?

i have two tables, i want to select everything from table 1 which has status > 3 and is NOT in table two. they are tied together by value called phoneName


{ Moved to PHP & Databases - Diablo84/PHP Page Editor }
0
qwertq
Asked:
qwertq
1 Solution
 
BatalfCommented:
by using a left join

example:

select table1.* from table1 left join table2 on table1.phoneName = table2.phoneName where table2.phoneName IS NULL and table1.status>3

It selects everything in table 1 where status>3 and where there's no match in table2

Batalf
0
 
qwertqAuthor Commented:
thanks!
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now