Help me : Where And Or

Any problem with SQL can be discussed here.
Locked
Mcbollard
Posts: 79
Joined: Sat Sep 09, 2006 12:23 am

Help me : Where And Or

Post by Mcbollard »

just wondering, when using 3+ criterater, how sql handles it


mohumben
Posts: 82
Joined: Thu Sep 15, 2005 9:45 pm

Post by mohumben »

What do you mean? Are you having any problems?

WHERE condition1 AND condition2 OR condition3

Code: Select all

define('I_LOVE_PHP', true);
vinter
Posts: 27
Joined: Fri Dec 22, 2006 5:08 pm

Post by vinter »

wtf does criterator mean?
csoftdev
Posts: 28
Joined: Fri Dec 07, 2007 4:49 pm

Post by csoftdev »

ask your question properly will be very helpful.
if you mean 3 conditions, then just use AND/OR to link up those conditions.
Tails5
Posts: 1302
Joined: Wed Mar 15, 2006 8:09 am
Contact:

Post by Tails5 »

He might mean criteria, perhaps

Code: Select all

SELECT * FROM myTable WHERE user = '$uid' AND password = '$pwd' AND email = '$email'
is what you want?
Webmaster Yoda: You must confront the cPanel. Then, and only then, a webmaster will you be.
Julius Caesar: Veni, vidi, posti
TheCrymsonLegends
Posts: 1246
Joined: Wed Feb 16, 2005 6:59 am

Post by TheCrymsonLegends »

That may be it but I think he wants to have it explained as how it works between mySQL and the php code.

If you are right Tails I would assume it means in order to get a query from the sql database you must match multiple parts from it. Such as a log-in page you would have to have your username, a password, and sometimes an image. If any three of them are incorrect then you will fail to query the sql database successfully to continue with the script. Normally from single criteria you would input something and it would query back anything from that table/section of the database. Such as a search engine.

Hope that is what you wanted, and thanks Tails you helped me with that line of code too lol.
Reached 5000 Credits! The highest of any member on Smokyhosts! New milestone for Me!
Lixas
Posts: 750
Joined: Wed Feb 16, 2005 4:21 pm

Post by Lixas »

mohumben wrote:What do you mean? Are you having any problems?

WHERE condition1 AND condition2 OR condition3
i dont realy know which keyword AND or OR has priority, so i dont realy know how sql engine will handle this query. Could be possible

Code: Select all

where [B]([/B]cond1 AND cond2[B])[/B] OR cond3
or

Code: Select all

where cond1 AND [B]([/B]cond2 OR cond3[B])[/B]
maybe someone could tell me exactly how "and" "or" are interpreted together in one query
Image
Tails5
Posts: 1302
Joined: Wed Mar 15, 2006 8:09 am
Contact:

Post by Tails5 »

I think that AND has a higher priority than OR, but I'm not exactly sure.
Webmaster Yoda: You must confront the cPanel. Then, and only then, a webmaster will you be.
Julius Caesar: Veni, vidi, posti
Gebbo
Posts: 554
Joined: Tue May 16, 2006 3:22 pm

sql

Post by Gebbo »

whats criterater :S lol its very hard to understand what your saying if your words are not accurate anyways sorry i couldnt help.
.............................:: Spirit of Fire ::..................................

Image
Locked