geroido Posted August 30, 2008 Share Posted August 30, 2008 Hi Can you see where the problem is with this query. It seems straightforward but is not working. There are no records in my database for the county 'Enniskillen' but it is retrieving all records where servType = 'Delivery only'. So it is getting records from the other counties who match Delivery only. I expect it to first look to see if Enniskillen exists, then if it does check that registered = 'yes', then give me all of those restaurants whose ServType = 'Delivery and restaurant booking' and servtype = 'Delivery only'. select clientID, busname, strAddr1, strAddr2, towncity, county, servType, registered FROM clientdetails where towncity = 'Enniskillen' and registered = 'yes' and servType = 'Delivery and restaurant booking' and servtype = 'Delivery only' Link to comment https://forums.phpfreaks.com/topic/121988-solved-query-retriving-wrong-records/ Share on other sites More sharing options...
fenway Posted August 30, 2008 Share Posted August 30, 2008 Please indicate how this was "solved" before marking it such. Link to comment https://forums.phpfreaks.com/topic/121988-solved-query-retriving-wrong-records/#findComment-629679 Share on other sites More sharing options...
geroido Posted August 30, 2008 Author Share Posted August 30, 2008 Having was the important bit left out instead of AND HAVING servType = 'Delivery and restaurant booking' and servtype = 'Delivery only' Link to comment https://forums.phpfreaks.com/topic/121988-solved-query-retriving-wrong-records/#findComment-629770 Share on other sites More sharing options...
fenway Posted August 30, 2008 Share Posted August 30, 2008 Not sure how that would have solved it.... but servtype can't be equal to 2 things at once! Link to comment https://forums.phpfreaks.com/topic/121988-solved-query-retriving-wrong-records/#findComment-629814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.