jonnyw6969 Posted May 27, 2008 Share Posted May 27, 2008 Hi all, Just a quick one. I have two tables, customers and orders. I want to select all the customer names who havent place an order. I select the ones that have placed an order like this SELECT customer.name from customer,order WHERE order.userid = customer.userid how do i select the ones who havent? Many Thanks Quote Link to comment Share on other sites More sharing options...
LooieENG Posted May 27, 2008 Share Posted May 27, 2008 SELECT customer.name from customer,order WHERE order.userid = customer.userid AND placed.order = 0 Edit: I think I read it wrong, lol Quote Link to comment Share on other sites More sharing options...
Pioden Posted May 27, 2008 Share Posted May 27, 2008 Also maybe SELECT customer.name from customer,order WHERE customer.userid != order.userid This *should* select all the customers who are not represented on the order table ... Quote Link to comment Share on other sites More sharing options...
AndyB Posted May 27, 2008 Share Posted May 27, 2008 order is a MySQL reserved word. You really should avoid naming tables or table fields using reserved words. http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html 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.