G3L0 Posted August 31, 2007 Share Posted August 31, 2007 hello. i've a problem here. i have 3 tables test1, test2, test3 that have SN and name as the field.when i want to search SN that match in that 3 tables i use this statement:select p.* from test1 p, test2 q, test3 r where p.mac_sn=q.mac_sn and p.mac_sn=r.mac_sn;it works. but how can i find SN that are not the same. Maybe this SN exist in test1 and test2 or test2 and test3 or test1 and test3 or even exist only in test1 or test2 or test3. i use '!=' to replace '=' in the statement above but what i get isn't wha i want. i've try it from yesterday and still can't figure it out.pls help me. thx Link to comment Share on other sites More sharing options...
justsomeguy Posted August 31, 2007 Share Posted August 31, 2007 If the database supports subqueries and union, you can use this: SELECT * FROM test1 WHERE mac_sn NOT IN (SELECT mac_sn FROM test2 UNION SELECT mac_sn FROM test3) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.