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-%' Quote 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] Quote Link to comment https://forums.phpfreaks.com/topic/2552-select-query/#findComment-8476 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.