Tuesday, 9 June 2020

select where clause

select where clause
SELECT column1, column2, ...
FROM table_name
WHERE condition;
SELECT * FROM Customers
WHERE Country='Mexico';
operator
where id =1
where id>1
where id < 1
where id >= 1
where id <=1
where id!=1
SELECT * FROM Products
WHERE Price <> 18;





BETWEEN
SELECT * FROM Products WHERE Price BETWEEN 50 AND 60;
SELECT * FROM Customers WHERE City LIKE 'p%';
it will display in price column which one has p leter than onw will show
SELECT * FROM Customers WHERE City = 'Paris' or city= 'London';
SELECT * FROM Customers WHERE City IN ('Paris','London');
SQL AND, OR and NOT Operators
SELECT column1, column2, ...
SELECT * FROM Customers
FROM table_name
WHERE Country='Germany' AND City='Berlin';
WHERE condition1 AND condition2 AND condition3 ...;
SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
SELECT column1, column2, ...
FROM table_name
other than this, it will displays all other than this in a particular row
WHERE NOT condition;


ON SOME TIMES WE CANT INSERT ROW, SO FILTER THAT
SELECT CustomerName, ContactName, Address
FROM Customers
WHERE Address IS NOT NULL;
SELECT CustomerName, ContactName, Address
FROM Customers
WHERE Address IS NULL;
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
UPDATE Customers
SET ContactName = 'Alfred Schmidt', City= 'Frankfurt'
AT THAT ID , UPDATA THE VALUES
WHERE CustomerID = 1;



using conditon
create table
SELECT * INTO newtable
FROM oldtable
WHERE 1 = 0;





No comments:

Post a Comment