ainoy31 Posted June 17, 2009 Share Posted June 17, 2009 Trying to query a table and one of the column can be values of either NULL, 0, or 1. Here is my query select complaint_flag, sessionid from table.orders where insert_date >= '2009-05-26' and order_status='done' and complaint_flag != '1' and complaint_flag is null That should return about 1636 rows but it returns zero. I am missing something here? Much appreciation. AM Link to comment https://forums.phpfreaks.com/topic/162653-solved-query/ Share on other sites More sharing options...
kickstart Posted June 17, 2009 Share Posted June 17, 2009 Hi select complaint_flag, sessionid from table.orders where insert_date >= '2009-05-26' and order_status='done' and complaint_flag != '1' and complaint_flag is null Why the 2 clauses? If the 2nd is true then the first is irrelevant. All the best Keith Link to comment https://forums.phpfreaks.com/topic/162653-solved-query/#findComment-858441 Share on other sites More sharing options...
ainoy31 Posted June 17, 2009 Author Share Posted June 17, 2009 Here is my solution: select complaint_flag, sessionid from govirs.orders where insert_date >= '2009-05-26' and order_status='done' and (complaint_flag != '1' or complaint_flag is null) I needed a () around my OR statement. I needed to account for the complaint_flag value to be null or zero. Later. AM Link to comment https://forums.phpfreaks.com/topic/162653-solved-query/#findComment-858446 Share on other sites More sharing options...
kickstart Posted June 17, 2009 Share Posted June 17, 2009 Hi Unless NULL has a different meaning on this column than 0 then I would be tempted to just give that column a default value of 0. All the best Keith Link to comment https://forums.phpfreaks.com/topic/162653-solved-query/#findComment-858459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.