SELECT Data from Table
Select and display all data can be done by using the following syntax:
The example in Figure 1 below shows how the SQL statement is used to retrieve and display the data in table "students".
Figure 1: Retrieve and display all data from table "students" |
User can choose to select and display a particular set column of data to be shown to the screen. The operation can be done using the SQL syntax below.
The example in Figure 2 below shows how the SQL statement is used to select and display only the student name column and the year of intake column in the table "students".
Figure 2: Select and display only 2 column from table "students". |
Specifying the column name in the SELECT statements can help to filter out the unwanted column in the data retrieve and display. How about filtering the data in row? The WHERE clause is use together with SELECT statements to filter out specific information in the database to be shown to the user. the syntax of WHERE in SELECT statements is shown below:
Figure 3 below shows how to select the data for a student called "Enson Liu" from the table "students":
Figure 3: Select data for student called "Enson Liu". |