In the article "Creating databases and database tables with MySQL," How do we create a database and database table and know how to add records to a database table? So how do we retrieve data from a database table?
1, from the database table to retrieve information
In fact, we've used a SELECT statement to retrieve information from a database table.
The SELECT statement format is generally:
Select retrieves the keyword from the retrieved table WHERE the search criteria (optional)
The previously used "*" indicates that all columns are selected. Let's continue with the table mytable that we created in the last article.
2, query all the data:
Mysql> select * FROM MyTable;
+----------+------+------------+----------+
| name | sex | Birth | birthaddr |
+----------+------+------------+--------+
| Abccs |f | 1977-07-07 | Our |
| Mary |f | 1978-12-12 | USA |
| Tom |m | 1970-09-02 | USA |
+----------+------+------------+----------+
3 row in Set (0.00 sec)
3. Correct Error Record:
If Tom's date of birth is wrong, should be 1973-09-02, you can use the UPDATE statement to fix: mysql> update mytable set birth = "1973-09-02" WHERE name = "Tom"; Then use the statements in 2 to see if they have been corrected.