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 Link to comment https://forums.phpfreaks.com/topic/107424-quick-and-easy-please-help/ 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 Link to comment https://forums.phpfreaks.com/topic/107424-quick-and-easy-please-help/#findComment-550663 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 ... Link to comment https://forums.phpfreaks.com/topic/107424-quick-and-easy-please-help/#findComment-550665 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 Link to comment https://forums.phpfreaks.com/topic/107424-quick-and-easy-please-help/#findComment-551209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.