HOME | PHP Tutorial | CSS
facebook icon
AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP
HTML Tutorial

CSS Tutorial

SQL WHERE AND & OR multiple conditions


The SQL AND & OR operators are used to combine multiple conditions to narrow data in an SQL statement. These two operators are called as the conjunctive operators.
The SQL AND condition and OR condition can be combined to test for multiple conditions in a SELECT, INSERT, UPDATE, or DELETE statement.

The AND Operator - how to create - example


Syntax
The basic syntax of the AND operator with WHERE is as −

Example 1: Syntax of the AND operator with WHERE
SELECT column1, column2, columnN
FROM table_name
WHERE [condition1] AND [condition2]...AND [conditionN];

Following is an example, which would fetch the ID, Surname and Fees fields from the USERS table, where the Fee is greater than 2525 AND the age is less than 30 years −

Example 2: the AND operator
SELECT ID, Surname, Fees
FROM USERS
WHERE Fee > 2525 AND age <30;


The OR Operator - Example - How to create

The OR operator is used to combine multiple conditions in an SQL statement's WHERE clause.

Example 3:The OR operator
SELECT column1, column2, columnN
FROM table_name
WHERE [condition1] OR [condition2]...OR [conditionN]



Following is an example, which would fetch the ID, Surname and Fees fields from the USERS table, where the Fee is greater than 2525 OR the age is less than 30 years −

Example 4: the AND operator
SELECT ID, Surname, Fees
FROM USERS
WHERE Fee > 2525 OR age <30;


Syntax The syntax for the AND condition and OR condition together in SQL is:

Example 5: the AND condition and OR condition together in SQL is:
SELECT column1, column2, columnN
FROM table_name
WHERE condition1 AND condition2 ... OR condition_n;


sql where and or SQL WHERE AND & OR multiple conditions - sql tutorial

881. MySQL Tutorial
MySQL Tutorial for Beginners - Learn MySQL in simple and easy steps starting from basic to advanced concepts with examples including database programming clauses command functions administration queries and usage along with PHP in simple steps. This tuto
https://www.tutorialspoint.com/mysql/index.htm

2571. SQL DISTINCT - SQL Tutorial

http://www.sql-tutorial.net/SQL-DISTINCT.asp

1942. Online SQL Server Tutorial, Examples, Software, Commands, Online Courses
Online SQL Tutorial pdf, what is SQL, Online Courses, Classes, Training, Tutorials for Beginners - agernic.com is a free interactive Code, Tags, Example
http://www.agernic.com/sql-tutorial.html

2588. SQL UPDATE - SQL Tutorial

http://www.sql-tutorial.net/SQL-UPDATE.asp

690. MySQL Tutorial - w3resource

https://www.w3resource.com/mysql/mysql-tutorials.php

2819. SQL Tutorial
Gives you clear, concise and easy to understand SQL tutorial with practical examples. You will learn how to write SQL query like a Pro.
http://www.zentut.com/sql-tutorial/

Your add here
How to get PHP errors to display?
How to prevent sql injection in php mysqli
How do I get PHP errors to display - PHP error_reporting()
mysql_query(): The mysql extension is deprecated and will be removed i
Function eregi_replace() is deprecated in php - How to fix
PHP delete an element from an array
Uncaught Error: Call to undefined function MYSQL_NUM_ROWS() in
Deprecated: mysql_connect() mysql extension is deprecated and will be
mysqli_fetch_array() expects parameter 1 to be mysqli_result boolean g
SQL IN Operator - example
SQL BETWEEN Operator
SQL like syntax and example
SQL WHERE AND & OR multiple conditions
SQL create table primary key autoincrement
PHP mysqli_connect () Function
SQL COUNT(), AVG() and SUM() Functions
Display data from SQL database with MySQLi into php - html table
SQL CREATE DATABASE - example
SQL mysql order by columns, by date, by asc, by desc, random with PHP
PHP mysqli_query() Function - mysqli query
SQL delete row - SQL delete table
SQL update - SQL update select
Insert into SQL - Insert into table SQL - Insert data in sql
Login in PHP - simple login script with PHP MYSQL