gusmacker Posted September 22, 2005 Share Posted September 22, 2005 I have a query that looks like the one below. The problem I am having is it doesn't even care about the request_status. It can be O or C (Opened Or Closed) and it will return it based on the rest of the info. How can I do a query to make sure the request_status is "O" and that the and the request_type matches one of those other ones? SELECT * FROM `ticket_table` WHERE `request_status` = 'o' AND `request_type` LIKE 'w-%' OR `request_type` LIKE 'd-%' OR `request_type` LIKE 'VOPN-%' Link to comment https://forums.phpfreaks.com/topic/2552-select-query/ Share on other sites More sharing options...
tharagleb Posted September 22, 2005 Share Posted September 22, 2005 Try this: SELECT * FROM `ticket_table` WHERE `request_status` = 'o' AND (`request_type` LIKE 'w-%' OR `request_type` LIKE 'd-%' OR `request_type` LIKE 'VOPN-%') Basically if you are using OR's you really should put them in parenthesis. I have a query that looks like the one below. The problem I am having is it doesn't even care about the request_status. It can be O or C (Opened Or Closed) and it will return it based on the rest of the info. How can I do a query to make sure the request_status is "O" and that the and the request_type matches one of those other ones? SELECT * FROM `ticket_table` WHERE `request_status` = 'o' AND `request_type` LIKE 'w-%' OR `request_type` LIKE 'd-%' OR `request_type` LIKE 'VOPN-%' 298022[/snapback] Link to comment https://forums.phpfreaks.com/topic/2552-select-query/#findComment-8476 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.