Jump to content

SELECT Query


gusmacker

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.