suffrinmick Posted February 10, 2009 Share Posted February 10, 2009 Hi. I've created a query in dreamweaver to extract emails from a customer list table against a "training courses booked" table, but I want to exclude customers who have cancelled or transferred from a course: SELECT DISTINCT customer_list.customer_no, customer_list.customer_name, course_title.course_title, courses.course_location, customer_list.postcode, customer_list.email FROM customer_training_info, customer_list, course_title, courses WHERE (postcode BETWEEN pcode_begin AND pcode_end AND date_booked BETWEEN begin AND end AND customer_training_info.customer_id = customer_list.customer_id AND customer_training_info.course_title_id = courses.course_id AND courses.course_title = course_title.ctID AND course_title.ctID = course01 AND customer_list.email != '') I can create a list of customers who have booked course01 (for example), and I can add to the end of my query: customer_training_info.cancel != 'TRUE' which will then only include any customers where cancelled is not true. I can also change this to: customer_training_info.transfer != 'TRUE' which will then include only customers where transferred is not true. But when I add this to the end of my query: AND ((customer_training_info.transfer != 'TRUE') || (customer_training_info.cancel != 'TRUE')) which I think should then include customers who have EITHER cancelled OR transferred, it doesn't work. Any ideas where I'm going wrong? Thanks Paul Quote Link to comment https://forums.phpfreaks.com/topic/144678-problem-with-or-operator-in-query/ Share on other sites More sharing options...
suffrinmick Posted February 10, 2009 Author Share Posted February 10, 2009 Sorry - should be: But when I add this to the end of my query: AND ((customer_training_info.transfer != 'TRUE') || (customer_training_info.cancel != 'TRUE')) which I think should then EXCLUDE customers who have EITHER cancelled OR transferred, it doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/144678-problem-with-or-operator-in-query/#findComment-759255 Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 != should be <> MySQL is weird that way. Give it a try and see if that works. Quote Link to comment https://forums.phpfreaks.com/topic/144678-problem-with-or-operator-in-query/#findComment-759297 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.