Database: SELECT Columns Intro

The SELECT command can be used with one table to select columns for the resulting table. This uses the Student table.

SELECT *

All of a table can be produced with
SELECT *
    FROM Student;
Result:
student_idstudent_fnamestudent_lnamestudent_gpa
1MickeyMouse2.5
4MinnieMouse3.8
2DonaldDuck2.0
3PeterRabbit3.6

SELECT field,...

To see the names of all students
SELECT student_fname, student_lname
    FROM Student;
Result:
student_fnamestudent_lname
MickeyMouse
MinnieMouse
DonaldDuck
Peter Rabbit

Arbitrary field order

The fields can be specified in any order.
SELECT student_lname, student_fname
    FROM Student;
Result:
student_lnamestudent_fname
Mouse Mickey
Mouse Minnie
Duck Donald
RabbitPeter

Column aliases

If the internal field names are not suitable, create an alias with AS.
SELECT student_lname AS Last, student_fname AS First
    FROM Student;
Result:
LastFirst
Mouse Mickey
Mouse Minnie
Duck Donald
RabbitPeter

Inserting constant columns

SELECT can be used to create new columns with constants in them. The column title varies with the DBMS used (eg, Access uses EXPR1001, MySQL uses the constant). You can choose a column name using AS, described above. Note: The ANSI standard says use single quotes around string constants and double quotes around aliases, but quotes may be treated differently in some DBMSes.
SELECT student_fname, ' has last name ', student_lname
    FROM Student;
Result:
student_fname has last name student_lname
Mickey has last name Mouse
Minnie has last name Mouse
Donald has last name Duck
Peter has last name Rabbit