MySQL OR Condition

The MySQL OR condition specifies that if you take two or more conditions then one of the conditions must be fulfilled to get the records as result.

Syntax:

snippet
WHERE condition1
OR condition2
...
OR condition_n;

Parameter explanation

condition1, condition2, ... condition_n: Specifies all conditions that must be fulfilled for the records to be selected.

MySQL OR Example

The following example specifies how to use the OR condition in MySQL with SELECT statement.

Consider a table "cus_tbl", having the following data:

MySQL OR Condition 1

Execute the following query:

snippet
SELECT *
FROM cus_tbl
WHERE cus_firstname = 'Ajeet'
OR cus_id > 100;

Output:

MySQL OR Condition 2

Note: In the above example you can see that the second condition "cus_id" is wrong but the query is displaying the correct result because of the OR condition.

Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents