

Use the asterisk character (*) in place of a column list in a SELECT statement to instruct MySQL to return every column from the specified table.

If you want to retrieve the data from every column in a table, you do not need to specify each column name after the SELECT keyword. The formatting does not affect the operation of a SQL statement you can use carriage returns and whitespace to format a query however you want.Īlthough it might seem excessive to adopt a formatting style for these simple examples, as you add more clauses to a query and learn to build more complex SQL statements in subsequent lessons, formatting your queries in a readable way becomes very important. In the examples in this book, queries are formatted so that each clause of a SQL statement is on a separate line. To add the weight column to the data retrieved, add it to the end of the list of columns selected, as follows: The columns in the output appear in the order given in the query. You can retrieve the values from two columns in the same query by specifying a list of columns after the SELECT keyword, separating them with a comma. Now you'll try another simple SELECT statement, this time on the products table.

#Mysql show tables command line how to
You will learn how to do this, by putting a filter on the query, in the next lesson. If your database is backed up and restored, or if a maintenance operation is performed on the database, MySQL might alter the order in which records are stored internally.Ī SELECT statement will return every row from the table unless you tell it otherwise. Although records are normally retrieved in the order in which they are inserted into the database, you cannot rely on a particular order being preserved.
