Page 71 - 2611_SmartGPT Pro V(5.0) C-8
P. 71

The syntax to use the SELECT command as follows:

                 SELECT * FROM table_name;
                 Where, * is used to select all the columns of the specified table.

                 To display all the data in the table, the SELECT command will be as follows:

























                 The SELECT command can also retrieve specific
                 fields from a table by listing the column names
                 instead of using the asterisk (*).

                 For example, to display only the StudentID and
                 FirstName  from  the  Students  table,  use  the
                 given command.









                                   If  a database is like  a treasure  chest  and you’re  the treasure  keeper,  how would
                                   you organise and store your precious items to make sure you can find them easily
                                   when needed?





                 THE WHERE CLAUSE
                 The SELECT command supports several optional clauses to refine your results. The WHERE clause

                 is one of the most useful, as it filters records based on specified conditions.
                 The syntax of the WHERE clause is as follows:

                 SELECT * FROM  table_name WHERE condition;

                 For example, to retrieve the records of all students with the last name ‘Sharma’, use the following
                 SELECT command:




                                                                                          MySQL: My First Database  69
   66   67   68   69   70   71   72   73   74   75   76