brown2005 Posted August 25, 2006 Share Posted August 25, 2006 $sql = "select * from table1 where members_id not in (select selected_id from table2 where 1)";is this correct as i cant get it to work Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 25, 2006 Share Posted August 25, 2006 [quote]select selected_id from table2 where 1[/quote]That isn't a valid sql query. Aside from your subselect being jacked, it should work.[code]SELECT * FROM table1 WHERE members_id NOT IN (SELECT selected_id FROM table2);[/code] Quote Link to comment Share on other sites More sharing options...
brown2005 Posted August 25, 2006 Author Share Posted August 25, 2006 SQL-query : SELECT * FROM websitesWHERE websites_id NOT IN (SELECT websites_hits_idFROM websites_hits)LIMIT 0 , 30 MySQL said: #1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT websites_hits_idFROM websites_hits ) LIMIT 0, 30' at li Quote Link to comment Share on other sites More sharing options...
Jenk Posted August 25, 2006 Share Posted August 25, 2006 sub selects were only added in mysql 5, check which version of mysql you have.Also, [code]SELECT * FROM `table` WHERE 1[/code] is a valid query, try it. 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.