Recent Articles



































Select (SQL)



         


A SELECT statement in SQL returns a result set of records from one of more tables.

[Top]

Examples

Table "T" Query Result
C1 C2
1 a
2 b
SELECT * FROM T;
C1 C2
1 a
2 b
C1 C2
1 a
2 b
SELECT C1 FROM T;
C1
1
2
C1 C2
1 a
2 b
SELECT * FROM T WHERE C1 = 1;
C1 C2
1 a

Given a table T, the query SELECT * FROM T; will result in all the elements of all the rows of the table being shown.

With the same table, the query SELECT C1 FROM T; will result in the elements from the column C1 of all the rows of the table being shown — in Relational algebra terms, a projection will be performed.

With the same table, the query SELECT * FROM T WHERE C1 = 1; will result in all the elements of all the rows where the value of column C1 is '1' being shown — in Relational algebra terms, a selection will be performed, because of the WHERE keyword.

See also:





  View Live Article   This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License