Jump to content


Photo

SELECT Query


  • Please log in to reply
1 reply to this topic

#1 gusmacker

gusmacker
  • Members
  • Pip
  • Newbie
  • 9 posts
  • LocationGrand Rapids, Michigan

Posted 22 September 2005 - 10:33 AM

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

[php:1:09d88d0ab6]<? [br]if ($SKYDIVING == "NO") { [br]$LIFE = EMPTY; [br]} else { [br]$LIFE = "FULL OF JOY"; [br]?> [br][/php:1:09d88d0ab6]

#2 tharagleb

tharagleb
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 22 September 2005 - 01:33 PM

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

View Post






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users