![]() |
query syntax and conditions
Hi
just curious, about a few things, I am going over my query's and changing || to OR adding brackets, stuff like that. I know its best to enclose different conditions from reading up whether you need too or not, separating "OR, AND" etc, just curious should I put both in brackets when they exist? or one over another? also should I always do AND conditions in the beginning no matter what? or are they ok at the end if using brackets? also is it good practice to use single quotes like '$var' in query, double or none at all. I'm strictly doing query's inside scripts only. Thanks as always Sonny |
Too general a question. Depends entirely upon what the WHERE condition is supposed to be testing.
Code:
WHERE age >= 18 OR age >= 16 AND parentalConsent = TrueIt means the same as Code:
WHERE age >= 18 OR ( age >= 16 AND parentalConsent = True )Code:
WHERE ( age >= 18 OR age >= 16 ) AND parentalConsent = True |
I did notice a weird result now and then but when I went back and
added some brackets, that fixed things. I thought using LIKE let me have a space before or after a word, without using that %, I really do not like using them if I can, I will pay more attention and use = whenever I can thanks PS "NOT IN" is another thing I need to go back and use now. its efficient, I like that. Thanks Sonny |
| All times are GMT +1. The time now is 05:54 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.