头哥数据库mysql基本查询
时间: 2024-01-10 08:04:26 浏览: 106
MySQL查询基本操作
MySQL是一种关系型数据库管理系统。以下是MySQL基本查询的例子:
1. 查询表中所有数据
SELECT * FROM table_name;
2. 查询表中指定列的数据
SELECT column1, column2, ... FROM table_name;
3. 按条件查询
SELECT * FROM table_name WHERE column_name = value;
4. 多条件查询
SELECT * FROM table_name WHERE column_name1 = value1 AND column_name2 = value2;
5. 模糊查询
SELECT * FROM table_name WHERE column_name LIKE '%value%';
6. 排序查询
SELECT * FROM table_name ORDER BY column_name;
7. 分组查询
SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name;
8. 连接查询
SELECT * FROM table1 JOIN table2 ON table1.column_name = table2.column_name;
9. 子查询
SELECT column_name FROM table_name WHERE column_name IN (SELECT column_name FROM table_name WHERE column_name = value);
以上是MySQL基本查询的例子,可以根据实际需求进行修改和扩展。
阅读全文