QT+SQL的常用语句
时间: 2023-09-17 08:08:25 浏览: 105
1. 创建表:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
...
);
2. 插入数据:
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
3. 更新数据:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
4. 删除数据:
DELETE FROM table_name
WHERE condition;
5. 查询数据:
SELECT column1, column2, ...
FROM table_name
WHERE condition;
6. 排序数据:
SELECT column1, column2, ...
FROM table_name
ORDER BY column1 ASC/DESC, column2 ASC/DESC, ...;
7. 连接查询:
SELECT column1, column2, ...
FROM table1
JOIN table2
ON table1.column = table2.column;
8. 分组统计:
SELECT column1, COUNT(column2)
FROM table_name
GROUP BY column1;
9. 子查询:
SELECT column1, column2, ...
FROM table_name
WHERE column1 IN (SELECT column1 FROM table2 WHERE condition);
10. 聚合函数:
SELECT COUNT(column1), SUM(column2), AVG(column3), MAX(column4), MIN(column5)
FROM table_name;
阅读全文