Click to See Complete Forum and Search --> : [RESOLVED] using brackets with my OR stmt ??


jeddik
11-13-2006, 01:46 PM
Hello

In my php/sql script below, should I use brackets with the OR ?

I want the confirm field to be either 'y' or it can be 's'.

Thanks for your help :)


$sql = "SELECT * FROM $section
WHERE feature in(' ','')
AND confirm = 'y' OR confirm = 's'
AND offwant = '$N_ow'
AND expire_date >= $today

Should it be written like this ?


$sql = "SELECT * FROM $section
WHERE feature in(' ','')
( AND confirm = 'y' OR confirm = 's' )
AND offwant = '$N_ow'
AND expire_date >= $today

karnetics
11-13-2006, 02:01 PM
I would do it the first way, but have you tried testing it to see if it works?

jeddik
11-13-2006, 02:48 PM
Well I have tested it and the first way seems to read

If ALL the other stuff is true OR the confirm = "s"
i.e. a record with confirm = "s" always comes up even if the other stuff is false.

The second way didn't work at all :confused:

What I want is:

If
ALL the other stuff is true
AND confirm = "y"

OR
ALL the other stuff is true
AND confirm = "s"


Any ideas ? :)

NogDog
11-13-2006, 04:10 PM
$sql = "SELECT * FROM $section
WHERE feature in(' ','')
AND (confirm = 'y' OR confirm = 's' )
AND offwant = '$N_ow'
AND expire_date >= $today ";

jeddik
11-14-2006, 02:34 AM
Thanks - that what I needed :)