Home Database Mysql Tutorial 从从MySQL数据库表中检索数据

从从MySQL数据库表中检索数据

Jun 07, 2016 pm 04:19 PM
mysql data database Search in the table

在《用MySQL创建数据库和数据库表》文章中,我们如何创建一个数据库和数据库表,并知道如何向数 据库表中添加记录。 那么我们如何从数据库表中检索数据呢? 1、从数据库表中检索信息 实际上,前面我们已经用到了SELECT语句,它用来从数据库表中检索信息。 sel

   在《用MySQL创建数据库和数据库表》文章中,我们如何创建一个数据库和数据库表,并知道如何向数 据库表中添加记录。 那么我们如何从数据库表中检索数据呢?

  1、从数据库表中检索信息

  实际上,前面我们已经用到了SELECT语句,它用来从数据库表中检索信息。

  select语句格式一般为:

  SELECT 检索关键词 FROM 被检索的表 WHERE 检索条件(可选)

  以前所使用的“ * ”表示选择所有的列。下面继续使用我们在上篇文章中创建的表 mytable。

  2、查询所有数据:

  mysql> select * from mytable;

  +----------+------+------------+----------+

  | name | sex | birth | birthaddr |

  +----------+------+------------+--------+

  | abccs |f | 1977-07-07 | china |

  | mary |f | 1978-12-12 | usa |

  | tom |m | 1970-09-02 | usa |

  +----------+------+------------+----------+

  3 row in set (0.00 sec)

  3、修正错误记录:

  假如tom的出生日期有错误,应该是1973-09-02,则可以用update语句来修正: mysql> update mytable set birth = "1973-09-02" where name = "tom"; 再用2中的语句看看是 否已更正过来。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

How to optimize MySQL query performance in PHP?

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

How to use MySQL backup and restore in PHP?

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into a MySQL table using PHP?

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

How to fix mysql_native_password not loaded errors on MySQL 8.4

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

How to use MySQL stored procedures in PHP?

70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI 70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI Jun 13, 2024 pm 03:47 PM

70B model generates 1,000 tokens in seconds, code rewriting surpasses GPT-4o, from the Cursor team, a code artifact invested by OpenAI

AI startups collectively switched jobs to OpenAI, and the security team regrouped after Ilya left! AI startups collectively switched jobs to OpenAI, and the security team regrouped after Ilya left! Jun 08, 2024 pm 01:00 PM

AI startups collectively switched jobs to OpenAI, and the security team regrouped after Ilya left!

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

How to create a MySQL table using PHP?

See all articles