Home | Previous Page | Next Page   Composing SELECT Statements > Single-Table SELECT Statements >

Using the Asterisk Symbol (*)

Figure 14 specifies all the columns in the manufact table in a projection list. An explicit select list is a list of the column names or expressions that you want to project from a table.

Figure 14. Query
SELECT manu_code, manu_name, lead_time FROM manufact

Figure 15 uses the wildcard asterisk symbol (*) as shorthand in the projection list to represent the names of all the columns in the table. You can use the asterisk symbol (*) when you want all the columns in their defined order. An implicit select list uses the asterisk symbol.

Figure 15. Query
SELECT * FROM manufact

Because the manufact table has only three columns, Figure 14 and Figure 15 are equivalent and display the same results; that is, a list of every column and row in the manufact table. Figure 16 shows the results.

Figure 16. Query Result
manu_code manu_name       lead_time 

 SMT       Smith              3
 ANZ       Anza               5
 NRG       Norge              7
 HSK       Husky              5
 HRO       Hero               4
 SHM       Shimara           30
 KAR       Karsten           21
 NKL       Nikolus            8
 PRC       ProCycle           9

Reordering the Columns

Figure 17 shows how you can change the order in which the columns are listed by changing their order in your projection list.

Figure 17. Query
SELECT manu_name, manu_code, lead_time FROM manufact 

Figure 18 includes the same columns as the previous query result, but because the columns are specified in a different order, the display is also different.

Figure 18. Query Result
manu_name       manu_code lead_time 
 
 Smith           SMT          3
 Anza            ANZ          5
 Norge           NRG          7
 Husky           HSK          5
 Hero            HRO          4
 Shimara         SHM         30
 Karsten         KAR         21
 Nikolus         NKL          8
 ProCycle        PRC          9
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]