Home >Database >Mysql Tutorial >What data operations does mysql have?

What data operations does mysql have?

PHPz
PHPzforward
2023-05-26 20:19:041513browse

1. Read data

select * from tb1;
select count(*) from tb1; #获取数据库条数  count(1)效果相同,效率更高

2. Insert data

INSERT INTO table_name ( field1, field2,...fieldN )
VALUES
( value1, value2,...valueN );

3. Update data

UPDATA tb1 SET name='li' where id=3;
UPDATA tb1 SET name=default where id=2; #将名字赋予默认值

4. Delete data

DELETE FROM tb1 where id=1;

5. Where condition query

select * where name='luo';
select * where BINARY name ='luo';  //数据库默认是不区分大小写的  用 BINARY来强调大小写

6. Like combined with regular expressions to query

SELECT * from tbl WHERE name LIKE '%o'; 查找所有名字由 o 结尾的记录

The above is the detailed content of What data operations does mysql have?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete