Home > Database > Mysql Tutorial > How to query a row of data in a table with mysql

How to query a row of data in a table with mysql

coldplay.xixi
Release: 2020-11-12 10:19:30
Original
11537 people have browsed it

Mysql method of querying a row of data in a table: Use the select statement to query, and use the where condition to select by row. The syntax is [select * from

where ].

How to query a row of data in a table with mysql

Mysql method of querying a row of data in a table:

Basic of Select statement Syntax:

Select <列的集合> from <表名> where <条件> order by <排序字段和方式>
Copy after login

If you want to query all the data of a specified row in a table, the query statement can be written as:

select * from <表名> where <条件>
Copy after login

Why is this statement? Let’s briefly analyze it. . So the data actually includes all rows and all columns, so:

1. First, select all columns

The "column set" should include all fields. You can use an asterisk (*) in an SQL statement to refer to all fields.

2. Then select the specified row

Use the where condition to select by row.

Let’s look at an example to query all records in the test table with a t_name value of name2:

mysql> select * from test where t_name=&#39;name2&#39;;
+------+--------+----------------------------------+------------+
| t_id | t_name | t_password                       | t_birth    |
+------+--------+----------------------------------+------------+
|    2 | name2  | 12345678901234567890123456789012 | 2013-01-01 |
+------+--------+----------------------------------+------------+
1 rows in set (0.00 sec)
Copy after login

More related free learning recommendations: mysql tutorial (video)

The above is the detailed content of How to query a row of data in a table with mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template