0% found this document useful (0 votes)
18 views1 page

4 MYSQL - SELECT - Query2

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

4 MYSQL - SELECT - Query2

to take knowledge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

-::SIMPLE QUERIES IN MYSQL::-

Sort the records in an ascending order of the field First_Name:


SELECT * FROM student ORDER BY First_Name;
Sort the records in a descending order of the field First_Name:
SELECT * FROM student ORDER BY First_Name DESC;
Find the list of students whose first name starts with “A”:
SELECT * FROM student WHERE First_Name LIKE "A%";
Find the list of students whose first name ends with “k”:
SELECT * FROM student WHERE First_Name LIKE "%k";
Display the record of students whose birth date comes before 01/04/2006:
SELECT * FROM student WHERE birth_date <= '2006-04-01';
Display the record of students whose birth date comes after 31/03/2005:
SELECT * FROM student WHERE birth_date >= '2005-03-31';
Display the record of students whose birth date comes BETWEEN 01/04/2005 and 31/03/2006:
SELECT * FROM student WHERE birth_date BETWEEN '2005-04-01' AND '2006-03-31';
Display the record of students whose birth date does not come BETWEEN 01/04/2005 and 31/03/2006:
SELECT * FROM student WHERE birth_date NOT BETWEEN '2005-04-01' AND '2006-03-31';
Returns records WHERE the Age is 14 AND City is Surat:
SELECT * FROM student WHERE age=14 AND city='surat';
SELECT * FROM student WHERE age=14 && city='surat';
Returns records WHERE the age is 14 OR City is Surat:
SELECT * FROM student WHERE age=14 OR city='surat';
SELECT * FROM student WHERE age=14 || city='surat';
Returns records WHERE the age is not equal to 14:
SELECT * FROM student WHERE NOT age =14;
SELECT * FROM student WHERE age !=14;
Returns records WHERE no value is entered in the City field:
SELECT * FROM student WHERE city IS NULL;
Returns records WHERE value is not missing in the City field:
SELECT * FROM student WHERE city IS NOT NULL;
Returns records WHERE the age is either 13 or 14:
SELECT * FROM student WHERE age IN(13, 14);
Returns records WHERE the age is neither 13 nor 14:
SELECT * FROM student WHERE age NOT IN(13, 14);

You might also like