Jump to content

Archived

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

gusmacker

SELECT Query

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-%'

Share this post


Link to post
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]

 

Share this post


Link to post
Share on other sites

×

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.