GKsea.com image

Serving the world with Accurate GK and Current Affairs

Advertisements

Syntax of SQL SELECT Statement With WHERE CLAUSE


Retrieving particular columns of a table
If you want to select few columns specifically from a table then you should use below syntax to get the task done.

General syntax

SELECT ColumnName1,ColumnName2 FROM table_name;

Here replace the table_name with the name of table you want to retrieve data from. And ColumnName1,ColumnName2 denotes the name of the columns separated by commas you want to include in output of your SQL select statement.

For Example: we have a table student in the database as below:

StudentIDStudentNameCityMobile
1001GautamJaipur9898988989
1002AliGoa9898988988
1003UpenMeerut9898988900
1004PuneetGoa9898988088
1005KarishmaMeerut9898958988
1006DimpiGoa9898988981
1007PreetamMeerut9898988985
1008SaurabhGoa9898988987
1009NishantGoa9898988986
1010SonaliDelhi9898988912
1010UmangDelhi989898894


Now if we write SELECT StudentID,StudentName FROM student;
Then Output will come as:
StudentIDStudentName
1001Gautam
1002Ali
1003Upen
1004Puneet
1005Karishma
1006Dimpi
1007Preetam
1008Saurabh
1009Nishant
1010Sonali
1010Umang

Previous Chapter|Next Chapter

SQL SELECT Statement With WHERE CLAUSE
If you want to filter the rows of some table using SQL then with SELECT statement we use WHERE CLAUSE.

General syntax

SELECT * FROM table_name WHERE row_filter_condition;

Here replace the table_name with the name of table you want to retrieve data from. And row_filter_condition can be anything having some operator on any column for examaple ColumnName1='value' etc.

For Example: we have a table student in the database as below:

StudentIDStudentNameCityMobile
1001GautamJaipur9898988989
1002AliGoa9898988988
1003UpenMeerut9898988900
1004PuneetGoa9898988088
1005KarishmaMeerut9898958988
1006DimpiGoa9898988981
1007PreetamMeerut9898988985
1008SaurabhGoa9898988987
1009NishantGoa9898988986
1010SonaliDelhi9898988912
1010UmangDelhi989898894


Now if we write SELECT * FROM table_name WHERE StudentName='Gautam';
Then Output will come as:
StudentIDStudentNameCityMobile
1001GautamJaipur9898988989

Previous Chapter|Next Chapter

Must Check


Advertisements

footer

Advertisements

Copyright© 2013-2015 Gksea.com. Powered by dataNcode | Disclaimer and Terms

Contact Us Mail Us