SELECT * FROM user WHERE uid >1 AND id
3、查询name以“张”开头的用户。
SELECT * FROM user WHERE name like '张%';
4、查询每个部门的总成本,以部门为单位进行统计。
SELECT department, SUM(cost) FROM employee GROUP BY department;
5、向user表中插入一条数据,id为3,username为“Tom”,password为“123456”,email为“tom@gmail.com”。
INSERT INTO user (id, username, password, email) VALUES (3, 'Tom', '123456', 'tom@gmail.com');
6、查找没有发布文章的用户。
SELECT * FROM user WHERE id NOT IN (SELECT DISTINCT uid FROM post);
以上就是一些MySQL训练题目的答案,不同难度的题目大家可以多练习,熟能生巧,加油吧!