Jump to content

Is there a limit to and/or statements or bracketing in a php sql query?


thminco

Recommended Posts

I'm trying to do an sql query from php that includes 15 condition "groups" each consisting of 4 conditions.  I have tried separating each condition group with brackets but still can't get it to work.  Am I missing something?

 

Thanks as always for everyone's help!!  Tom

 

Here is the code shown with line breaks for clarity:

 

 

$query="SELECT * FROM d4dauctions

 

WHERE (`user gender` LIKE '%$gender%'

AND `auction area` LIKE '%$auctionarea%'

AND `user age group` LIKE '%$agegroup%'

AND `type of bid` LIKE '%$typeofbid%')

 

OR  ('$usergender' = 'Either'

AND `auction area` LIKE '%$auctionarea%'

AND `user age group` LIKE '%$agegroup%'

AND `type of bid` LIKE '%$typeofbid%')

 

OR  ('$auctionarea' = 'Anywhere'

AND `user gender` LIKE '%$gender%'

AND `user age group` LIKE '%$agegroup%'

AND `type of bid` LIKE '%$typeofbid%')

 

OR  ('$agegroup' = 'Any age'

AND `user gender` LIKE '%$gender%'

AND `auction area` LIKE '%$auctionarea%'

AND `type of bid` LIKE '%$typeofbid%')

 

OR  ('$typeofbid' = 'Any type of bid'

AND `user gender` LIKE '%$gender%'

AND `auction area` LIKE '%$auctionarea%'

AND `user age group` LIKE '%$agegroup%')

 

OR  ('$usergender' = 'Either'

AND '$auctionarea' = 'Anywhere'

AND `user age group` LIKE '%$agegroup%'

AND `type of bid` LIKE '%$typeofbid%')

 

OR  ('$usergender' = 'Either'

AND `auction area` LIKE '%$auctionarea%'

AND '$agegroup' = 'Any age'

AND `type of bid` LIKE '%$typeofbid%')

 

OR  ('$usergender' = 'Either'

AND `auction area` LIKE '%$auctionarea%'

AND `user age group` LIKE '%$agegroup%'

AND '$typeofbid' = 'Any type of bid')

 

OR  (`user gender` LIKE '%$gender%'

AND '$auctionarea' = 'Anywhere'

AND '$agegroup' = 'Any age'

AND `type of bid` LIKE '%$typeofbid%')

 

OR  (`user gender` LIKE '%$gender%'

AND '$auctionarea' = 'Anywhere'

AND `user age group` LIKE '%$agegroup%'

AND '$typeofbid' = 'Any type of bid')

 

OR  (`user gender` LIKE '%$gender%'

AND `auction area` LIKE '%$auctionarea%'

AND '$agegroup' = 'Any age'

AND '$typeofbid' = 'Any type of bid')

 

OR  ('$usergender' = 'Either'

AND '$auctionarea' = 'Anywhere'

AND '$agegroup' = 'Any age'

AND `type of bid` LIKE '%$typeofbid%')

 

OR  ('$usergender' = 'Either'

AND `auction area` LIKE '%$auctionarea%'

AND '$agegroup' = 'Any age'

AND '$typeofbid' = 'Any type of bid')

 

OR  ('$usergender' = 'Either'

AND '$auctionarea' = 'Anywhere'

AND `user age group` LIKE '%$agegroup%'

AND '$typeofbid' = 'Any type of bid')

 

OR  ('$usergender' = 'Either'

AND '$auctionarea' = 'Anywhere'

AND '$agegroup' = 'Any age'

AND '$typeofbid' = 'Any type of bid')

 

ORDER BY RANK DESC

";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.