SQL OR

Learn SQL OR clause to add one or more conditions and filter result when anyone condition is true . Display result when anyone condition met using OR clause.

The OR clause can be used to manipulate the record only when anyone of the specified condition is true. It can be useful when you need to add many useful rules and filter result when any of the rule is true, you can fetch the required result from the table.

You can use the OR clause with SELECT, INSERT, UPDATE AND DELETE statements.

How to Use SQL OR Clause with WHERE Clause to Filter Result Based on Anyone Condition is True

The syntax to use the SQL OR clause with SELECT, INSERT, UPDATE and DELETE statements is given below. You can use multiple condition in WHERE clause. However, it’s optional to use the WHERE clause with the statement.

Syntax1: SELECT Statement with OR Clause

The above syntax contains the SELECT statement with the single column and two optional conditions with OR clause. In addition to this, If you want to add more than one column, you have to specify the column with comma separation and more than two conditions with OR clause in them.

Syntax2: UPDATE Statement OR Clause.

You can update the rows of a column with the syntax given above. You can specify more than one condition and update the exact record of a table using the multiple conditions. Don’t forget to specify the condition in the WHERE clause. If you forget to specify the condition, the above syntax updates all the record of the specified column.

Syntax3: DELETE Statement with OR Clause

Delete the record from the table by using themore than one condition. The above syntax deletes the rows from the table only when all the specified condition is true. If you do not specify any condition in the WHERE clause, the above syntax will delete all the records of a table.

Parameter Descriptions

Sr.No Parameter Name Description
1 column_name Enter the name of the colum to which you want to multiple filter WHERE condition and display the required rows when anyone of the condition is true. If you want to select all the columns, you can use the symbol (*). In addition to this, you can add multiple columns with comma(,) separation.
2 tablename Enter the name of the table to which you want to apply the filter using the multiple conditions.
3 condition1 You can specify the first condition with the operator, columns, and value.
4 condition2 Specify the second condition with the operator, columns, and values to apply in the WHERE clause.

You must also learn.

Reference