Retrieving data from a MySQL database table

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.