Creating a query with AND'S and OR's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
waynobweno
Forum Newbie
Posts: 2
Joined: Fri May 15, 2009 1:34 pm

Creating a query with AND'S and OR's

Post by waynobweno »

Hi,

I have a query that is not working.

query => select * from products where a = '1' AND b = '2' AND c = '3' AND holespacing_decimal IN ('3.00','5.04') OR holespacing_decimal_two IN ('3.00','5.04') OR holespacing_decimal_three IN ('3.00','5.04')

The issue that I am having is that when I use OR's along with AND's everything before the OR's basically gets ignored in the query.

Is there a way to use multiple AND's and multiple OR's in a sql statement. I need to be able to create all of the first statements a = 1, b = 2, and c = 3 and then use the OR's to search these 3 holespacing columns...

Is this possible?

Thanks for you help!
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Creating a query with AND'S and OR's

Post by requinix »

Use parentheses.

Really. Why didn't you think of that?
Post Reply