m11oct Posted September 13, 2006 Share Posted September 13, 2006 If you don't know about MySQL syntax then please just ignore this post... I'm having a MySQL Query problem as I don't know how to write it... I want to select columns B and C from TABLE2 if the value from C in TABLE1 doesn't exist as a column A in TABLE1 at all. Column A is the index for TABLE1 and column B is the index for TABLE2 while column C in TABLE2 refers to a row from TABLE1. However, it appears there are quite a lot of cases in TABLE2 where the row column C referes to in TABLE1 no longer exists and I'd like to be able to select all of these. Any ideas? Quote Link to comment Share on other sites More sharing options...
shoz Posted September 13, 2006 Share Posted September 13, 2006 [quote=m11oct]if the value from C in TABLE1 doesn't exist as a column A in TABLE1 at all.[/quote]Did you mean C in TABLE2?[code]SELECTtable2.B, table2.CFROMtable2LEFT JOIN table1ONtable2.C = table1.AWHEREtable1.A IS NULL[/code]http://dev.mysql.com/doc/refman/4.1/en/join.html Quote Link to comment Share on other sites More sharing options...
m11oct Posted September 14, 2006 Author Share Posted September 14, 2006 That works well, thank you very much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.