FRIHOSTFORUMSSEARCHFAQTOSBLOGSCOMPETITIONS
You are invited to Log in or Register a free Frihost Account!


SQL WHERE





imagefree
(Mods where to put SQL Questions and discussion?)


while reading an online tutorial, i read this example:



Code:
True AND False OR True AND True OR False AND False

First simplify the AND pairs:

False OR True OR False

Now do the OR's, left to right:

True OR False
True


can someone please explain how to evaluate the condition that is in the first line? A little bit explaination is also there but its my first day on SQL, so cant understand that. Please help me by providing step by step solution working just like processor/compilor.

http://www.intermedia.net/support/sql/sqltut.asp
Drag the page a littlebit to see the example there in the actual tutorial.


Thanks
kv
If you know how the logical operator operations (AND/OR), this should explain it.
Code:


True AND False OR True AND True OR False AND False

First simplify the AND pairs: (True AND False) OR (True AND True) OR (False AND False)
=
False OR True OR False

Now do the OR's, left to right: (False OR True) OR False
=
True OR False
True

imagefree
kv wrote:
If you know how the logical operator operations (AND/OR), this should explain it.
Code:


True AND False OR True AND True OR False AND False

First simplify the AND pairs: (True AND False) OR (True AND True) OR (False AND False)
=
False OR True OR False

Now do the OR's, left to right: (False OR True) OR False
=
True OR False
True



it means TRUE & FALSE, FALSE & FALSE, FALSE & TRUE, always amount to false!!!??
roboguyspacedude
OR in this case supercedes AND. Any OR statement that is false on one side but true on the other makes the statement true, but any AND statement that is false on one side and true on the other is false.

in order for a AND statement to be true both sides must be true.
so thus you break this statement
Code:
True AND False OR True AND True OR False AND False

into parts
Part I: True AND False = false - since like i said both sides just be true for it to be true
Part II: True AND True = true - because both sides are true
Part III: False AND False = false - obvious
so those are then joined by the OR statements
false OR true OR false
the two falses are the same so you can get rid of one so
true OR false
and since it is OR it doesn't matter if only one side is true, so whole thing is true.

Usually I separate these kind of statements with parentheses to make it clear to the program what I mean.
kv
FALSE AND TRUE = FALSE
FALSE AND TRUE = FALSE
TRUE AND TRUE = TRUE
FALSE AND FALSE = FALSE

TRUE OR FALSE = TRUE
TRUE OR TRUE = TRUE
FALSE OR TRUE = TRUE
FALSE OR FALSE = FALSE
Related topics
Help: SQL error after uploading new files(thread updated)
have problem on my sql
SQL Basics
MySQL backup, cant find where to load them
SQL - need help
Sql Error: 1017. Missing all the indexes files of phpbb
Best way to prevent SQL injection attacks
Where can I start to make my own CMS?
SQL error
I can't install any scripts involving SQL properly.
SQL.....Where to start?
AJUDA INSTRUÇÃO SQL WHERE!
How to resolve these URIs?
Create Function to create SQL dynamically
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.