Jump to content


Photo

Query Help


  • Please log in to reply
2 replies to this topic

#1 Kelset

Kelset
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 18 May 2006 - 06:32 PM

Hello All!

I hate to be bugging you folks but I have a newbie question that I can not seem to figure out.
I have a DB with fields (name,dis,S,F,W,state) the S,W,F are set to enum ('true','false'). Ok now
the query I need to run on this is what has me going insane.

I would like to query where the dis equals someting and the state equals and the F or W or S egual
somthing. I know I am not explaining this very well and for that I am sorry.

Here is as far as I can make it :(

$query = "SELECT * FROM tableName WHERE dis='value' and state='value'"

the above is simple and works great but I get the values for S,W,F from an array
so there might be a S and a W. So I would like to see all the jobs that have dis='value'
and state='vale' and have either a S or a W='true'

Maybe I'm just dreaming of the impossiable, sure hope not :(

Any help would be great and thank you for you time in helping me

Stephen

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 18 May 2006 - 07:48 PM

Try the following (UNTESTED):

SELECT * FROM tableName WHERE dis='value' and state='value' AND ( s = 'true' OR w = 'true' )

Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 Kelset

Kelset
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 19 May 2006 - 11:56 PM

This seems to do the trick thank you so much. I was wondering how I was going to do this and
even tried your code but with out the brackets (doh!). Again thanks for the help, if you have time
maybe explain it to me.

Cheers!
Stephen




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users