作者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/m.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