SQL WHERE CLAUSE
SQL WHERE CLAUSE:
Where clause is use to get the exact value from a record.
You can also get values by giving condition.
DATABASE TABLE:
item table
Itemcode |
Itemname |
Price |
4001 |
Pen |
50 |
4002 |
Pencil |
20 |
4003 |
notebook |
40 |
SQL WHERE SYNTAX:
SELECT column1,column2...FROM Table_Name WHERE condition;
SELECT column1,column2...FROM Table_Name WHERE condition;
EXAMPLE:
SELECT itemname, price FROM item where itemcode = 4001;
The OUTPUT for the above code:
Itemname |
Price |
Pen |
50 |
WHERE clause :
To select a particular record from the table.
Itemcode |
Itemname |
Price |
4001 |
Pen |
50 |
4002 |
Pen |
20 |
4003 |
notebook |
40 |
SYNTAX:
SELECT * FROM Table_Name WHERE condition;
SELECT * FROM Table_Name WHERE condition;
EXAMPLE:
SELECT * FROM item WHERE itemname='pen';
The OUTPUT for the above code:
Itemcode |
Itemname |
Price |
4001 |
Pen |
50 |
4002 |
Pen |
20 |