作者oklp1415 (天生我材)
看板Database
标题[SQL ] 资料查询问题
时间Fri Jan 23 16:39:13 2015
(针对
SQL 语言的问题,用这个标题。请用 Ctrl+Y 砍掉这行)
资料库名称:MYSQL
资料库版本:MySQL 伺服器版
内容/问题描述:
http://ppt.cc/ITNl
select name.age from personnel
where salary>45000 and department =
(select department from personnel where
salary > 40000 group by department
having count(department);
关於我的,语法请益
我下这样的查询语法,总是会爆错,不知道哪里不符合文法的逻辑呢?
资料库一直捞不到以建立好的资料。
谢谢!!
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.39.0.180
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Database/M.1422002356.A.82C.html
1F:→ cocobox: 错好多地方,你要不要重写一次.... 01/23 17:14
不知道大大可以指导一下吗^^"
※ 编辑: oklp1415 (118.171.38.31), 01/23/2015 22:42:25
2F:→ cocobox: select name.age from personnel 01/24 08:36
3F:→ cocobox: where salary>45000 and department = 01/24 08:37
4F:→ cocobox: (select department from personnel where 01/24 08:38
5F:→ cocobox: salary > 40000 group by department 01/24 08:38
6F:→ cocobox: having count(department); 01/24 08:38
这样还是有爆错的情况
You have an error in your SQL syntax; check the manual that for the right syntax to use near '' at line 5: select name.age from
personnel where salary>45000 and department = (select department from
personnel where salary > 40000 group by department having count(department)
※ 编辑: oklp1415 (118.171.40.176), 01/24/2015 23:29:57
7F:→ Ammenze: 你的having後面没有条件式,还有子查询最後少个) 01/29 10:31