0% found this document useful (0 votes)
4 views2 pages

NOT Operator: Insert Into

The document provides SQL commands for various database operations including selection, insertion, updating, and deletion of records in a Customers table. It illustrates the use of NOT operators, the INSERT INTO statement, the UPDATE clause, and the DELETE clause, along with examples for selecting the top records in different SQL dialects. Additionally, it explains the use of the LIKE and IN operators for pattern matching and filtering results.

Uploaded by

rahulkrishna80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

NOT Operator: Insert Into

The document provides SQL commands for various database operations including selection, insertion, updating, and deletion of records in a Customers table. It illustrates the use of NOT operators, the INSERT INTO statement, the UPDATE clause, and the DELETE clause, along with examples for selecting the top records in different SQL dialects. Additionally, it explains the use of the LIKE and IN operators for pattern matching and filtering results.

Uploaded by

rahulkrishna80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

NOT Operator

SELECT * FROM Customers WHERE CustomerName NOT LIKE 'A%';

SELECT * FROM Customers WHERE CustomerID NOT BETWEEN 10 AND 60;

SELECT * FROM Customers WHERE City NOT IN ('Paris', 'London');

(Not Greater Than)SELECT * FROM Customers WHERE NOT CustomerID > 50;

(Not Less Than)SELECT * FROM Customers WHERE NOT CustomerId < 50;

INSERT Into

INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode,


Country)
VALUES
('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway'),
('Greasy Burger', 'Per Olsen', 'Gateveien 15', 'Sandnes', '4306', 'Norway'),
('Tasty Tee', 'Finn Egan', 'Streetroad 19B', 'Liverpool', 'L1 0AA', 'UK');

Update Clause

UPDATE Customers SET ContactName='Juan' WHERE Country='Mexico';

Delete Clause

Delete specific record:- DELETE FROM Customers WHERE CustomerName='Alfreds


Futterkiste';

Delete All record (but structure, attributes, indexes will be intact):-


DELETE FROM Customers ;

Delete the Table structure also:- DROP TABLE Customers;

Select Top10

SQL Server/MS Access MySQL Oracle


SELECT TOP 3|Top 50 percent * SELECT * FROM Customers SELECT * FROM Customers
FROM Customers; LIMIT 3; FETCH FIRST 3 ROWS ONLY;
SELECT TOP 3 * FROM Customers SELECT * FROM Customers SELECT * FROM Customers
ORDER BY CustomerName DESC; ORDER BY CustomerName DESC ORDER BY CustomerName DESC
LIMIT 3; FETCH FIRST 3 ROWS ONLY;
SELECT TOP 30
percent * FROM Customers
ORDER BY CustomerName DESC;

The percent sign % represents zero, one, or multiple characters


SELECT * FROM Customers WHERE CustomerName LIKE 'a%';

LIKE 'a%', ‘%ab%’, ’%ab ’ ;

The IN operator is a shorthand for multiple OR conditions.

SELECT * FROM Customers WHERE Country IN ('Germany', 'France', 'UK'); same as below

SELECT * FROM Customers WHERE Country = 'Germany', OR 'France', OR 'UK';

You might also like