sql select query

SQL Select Query

Select query in the SQL (structured query language) is used to display data from the table. Query – SELECT * FROM table;

Bypassing conditions with this query, we can display data accordingly, we want to see or of a particular column.

SQL “SELECT” query syntax

SELECT columns FROM table;

Example table-

example image for select query

Select all columns (*) of the table

To select all columns of a table, use a symbol called asterisk or star (*).

SELECT * FROM users;

Select one column of the table

SELECT state FROM users; // to view the data of the state columnn


SELECT name FROM users; // to view the data of the name columnn

Select two or more columns of the table

SELECT name,mon_income FROM users; // to view the data of the name & monthly income

SELECT all (*) columns with WHERE condition

SELECT * FROM users WHERE mon_income="20000";

SELECT one column with WHERE condition

SELECT name FROM users WHERE gender="Male";

SELECT two columns with WHERE condition

SELECT name,mon_income FROM users WHERE state="RJ";

Select query not only pulls data from the table but also you can do calculations with them. SELECT mon_income*2 FROM users;

Display selected data in another temporary column

SELECT mon_income, mon_income*2 AS double_income FROM users;

Leave a Comment