0% found this document useful (0 votes)
7 views

Table - Name Column1 Column2 Column3 Value1 Value2 Value3 Table - Name Value1 Value2 Value3

fgfgfgggggggggggggggggggggggggggggggggg gggggggggggg fjgh kgjfh gjfhgj fgjhfj gfjh gjfhgjfhgjfh gjfhjghfjghf jghf jg hfjhg jfh gjfhghfjg fjh jfhgjf hjghf

Uploaded by

telugu tech gana
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Table - Name Column1 Column2 Column3 Value1 Value2 Value3 Table - Name Value1 Value2 Value3

fgfgfgggggggggggggggggggggggggggggggggg gggggggggggg fjgh kgjfh gjfhgj fgjhfj gfjh gjfhgjfhgjfh gjfhjghfjghf jghf jg hfjhg jfh gjfhghfjg fjh jfhgjf hjghf

Uploaded by

telugu tech gana
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SQL

1. Select * from table_name ;


2. Select column 1, column 2 from table_name;
3. Select distinct name from table_name;
4. Select distinct column 1, column 2 from table_name;
5. Select column from table_name;

COUNT :

6. Select count (distinct column) from table_name;


7. Select * from table_name where column=’’;
8. Select * from table_name where column=’’;
9. Select * from table_name where column > count (like 20);

ORDER BY :

10. Select * from table_name ORDER BY column name;


11. Select * from table_name ORDER BY column DESC;
12. Select * from table_name ORDER BY column1, column2;
13. Select * from table_name ORDER BY column ASC;

Where :

14. Select * from table_name where column1=’’ AND column2=’’ like ‘G%’;
15. Select * from table_name where column1=’’ AND column2=’’ like ‘G%’ AND column3=’’;
16. Select * from table_name where column1=’’ AND column2=’’ like ‘G%’ AND column3>’’;

OR :

17. Select * from table_name where column1=’’ AND (column2=’’ like ‘G%’ OR column=’T%’);
18. Select * from table_name where column1=’’ OR column2=’T%’;

NOT :

19. Select * from table_name where NOT column1=’’;


20. Select * from table_name where NOT LIKE ’A%’;
21. Select * from table_name where NOT BETWEEN 10 AND 60;

Insert

22. INSERT INTO table_name (column1, column2, column3, ...)


VALUES (value1, value2, value3, ...);

23 INSERT INTO table_name


VALUES (value1, value2, value3, ...);

24. INSERT INTO Customers (CustomerName, ContactName, Address,


City, PostalCode, Country)
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen
21', 'Stavanger', '4006', 'Norway');
25 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');

Null

26.

SELECT column_names
FROM table_name
WHERE column_name IS NULL;

27.

SELECT column_names
FROM table_name
WHERE column_name IS NOT NULL;

Update :

28.

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

DELETE :

29.

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

30.

Create table using quary

create table students (id int, name varchar, roll_number int,email varchar, dob int,phone int);CO
Update quarey

Update Table_name set id = ‘5’. Name = ‘fsfsf’ where name = ‘dsjds’

Alter quary

alter table Students add marks int; (add)

alter table Students drop marks; (delete)

alter table Students rename column id to ID; (rename)

Some of The Most Important SQL


Commands
 SELECT - extracts data from a database
 UPDATE - updates data in a database
 DELETE - deletes data from a database
 INSERT INTO - inserts new data into a database
 CREATE DATABASE - creates a new database
 ALTER DATABASE - modifies a database
 CREATE TABLE - creates a new table
 ALTER TABLE - modifies a table
 DROP TABLE - deletes a table
 CREATE INDEX - creates an index (search key)
 DROP INDEX - deletes an index

DISTINCT : the quary is used to show the unique value from the column

Example : SELECT DISTINCT first_name from Customers;

SELECT Example Without DISTINCT


If show all the daa from column

Example
SELECT Country FROM Customers;

You might also like