MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology


Select in MySQL
Previous Home Next

The most commonly used command in mysql is SELECT statement. It is used to retrieve the selected data according to the conditions specified. In simple words, we can say that the select statement used to query or retrieve data from a table in the database. Here is the syntax of select statement.

SELECT expressions
FROM tables
WHERE conditions;

There are some optional clause in the Select statement, they are define as follows:

  1. where: It gives the specific conditions.
  2. Group by: It gives the aggregate function applied at each group.
  3. Order by: It gives the output according to the order specified.
  4. Having by: It gives the output among the groups defined by the GROUP BY clause.

Here i have shown some examples of the Select statement.

i have use a table name studinfo From the database school whose view as given below:

basic Select Query is given below

SELECT * 		//'*' uses to show all value
FROM studinfo;		//studinfo is a tablename


After execute this query we got the result as image given below

Output become

Note: use asterisk (*) to display all the data from a selected table

Now if we want some selected columns like fname and lname so we can use the below code

SELECT sid, fname, lname  	//select fname and lname 
FROM studinfo;			//studinfo ia a tablename

Output become

use another condition where full syntax of Select can be use


SELECT * 			//show all the value
FROM studinfo			//studinfo is tablename
WHERE sid > 106;		//conditions given here > 0

Output become

use some optional clause in the select statement


SELECT * 			//show all the value
FROM studinfo 			//studinfo is tablename
ORDER BY fname;			//order condistion write here

Output become


SELECT fname 			//show only fname
AS Name 			//show heading as column Name
FROM studinfo;			//studinfo is tablename

Output become

In the above code AS can be use to given output columnname, like Name.

Previous Home Next