SQL Select Statement

The Select statement is used to select or fetch data from the database table.The data return from the database table as the result table is also known as the result-set.

SELECT Syntax :

The syntax of the SELECT statement is −

SELECT column1, column2, column3, columnN FROM table-name;

column1 , column2, column3: names of the fields of the table table-name: table where we want to fetch data

If we want to select all the columns from the respective table then we use the following syntax:

SELECT * FROM table-name;



SELECT Example :

Consider the Customer table with the following records -

CustomerID CustomerName Age Address CustomerSalary
1 Aarav 28 Bangalore 28000
2 Vivaan 25 Mumbai 30000
3 Reyansh 30 Chennai 35000
4 Muhammad 24 Udaipur 50000
5 Sai 30 Indore 27000


Test Case:-The following code is an example, which would fetch the CustomerName and Address fields of the Customer available in Customer table.

SELECT CustomerName, Address FROM Customer;


The result for the respective sql query is as follows −

CustomerName Address
Aarav Bangalore
Vivaan Mumbai
Reyansh Chennai
Muhammad Udaipur
Sai Indore

Exercise:-

1. Which of the following statements contains an error?

A. Select * from emp where empid = 10003;
B. Select empid from emp where empid = 10006;
C. Select empid from emp;
D. Select empid where empid = 1009 and lastname = ‘GELLER’;

View Answer


2. Which of the following statements does not contains an error?

A. Select where empid = 10003;
B. Select empid from emp where empid = 10006;
C. Select empid from emp
D. Select empid where empid = 1009 and lastname = ‘GELLER’;

View Answer







Visit :


Discussion



* You must be logged in to add comment.

pHqghUme
555

pHqghUme
555

pHqghUme
555

pHqghUme
-1 OR 2+617-617-1=0+0+0+1 --

pHqghUme
-1 OR 3+617-617-1=0+0+0+1 --

pHqghUme
-1 OR 3*2<(0+5+617-617) --

pHqghUme
-1 OR 3*2>(0+5+617-617) --

pHqghUme
-1 OR 2+19-19-1=0+0+0+1

pHqghUme
-1 OR 3+19-19-1=0+0+0+1

pHqghUme
-1 OR 3*2<(0+5+19-19)

pHqghUme
-1 OR 3*2>(0+5+19-19)

pHqghUme
-1' OR 2+576-576-1=0+0+0+1 --

pHqghUme
-1' OR 3+576-576-1=0+0+0+1 --

pHqghUme
-1' OR 3*2<(0+5+576-576) --

pHqghUme
-1' OR 3*2>(0+5+576-576) --

pHqghUme
-1' OR 2+279-279-1=0+0+0+1 or 'Fq6X8mm0'='

pHqghUme
-1' OR 3+279-279-1=0+0+0+1 or 'Fq6X8mm0'='

pHqghUme
-1' OR 3*2<(0+5+279-279) or 'Fq6X8mm0'='

pHqghUme
-1' OR 3*2>(0+5+279-279) or 'Fq6X8mm0'='

pHqghUme
-1" OR 2+203-203-1=0+0+0+1 --

pHqghUme
-1" OR 3+203-203-1=0+0+0+1 --

pHqghUme
-1" OR 3*2<(0+5+203-203) --

pHqghUme
-1" OR 3*2>(0+5+203-203) --

pHqghUme
if(now()=sysdate(),sleep(15),0)

pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z

pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z

pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

pHqghUme
-1; waitfor delay '0:0:15' --

pHqghUme
-1); waitfor delay '0:0:15' --

pHqghUme
1 waitfor delay '0:0:15' --

pHqghUme
LlarZJH3'; waitfor delay '0:0:15' --

pHqghUme
-5 OR 269=(SELECT 269 FROM PG_SLEEP(15))--

pHqghUme
-5) OR 59=(SELECT 59 FROM PG_SLEEP(15))--

pHqghUme
-1)) OR 546=(SELECT 546 FROM PG_SLEEP(15))--

pHqghUme
LyUBvuib' OR 533=(SELECT 533 FROM PG_SLEEP(15))--

pHqghUme
LLgTklBX') OR 358=(SELECT 358 FROM PG_SLEEP(15))--

pHqghUme
akp5y7Z1')) OR 379=(SELECT 379 FROM PG_SLEEP(15))--

pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

pHqghUme
1'"

pHqghUme

pHqghUme
@@fIur4

pHqghUme
555

pHqghUme
555

pHqghUme
555