[SQL ] 資料查詢問題

看板Database作者 (天生我材)時間11年前 (2015/01/23 16:39), 11年前編輯推噓0(007)
留言7則, 2人參與, 最新討論串1/2 (看更多)
(針對 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://www.ptt.cc/bbs/Database/M.1422002356.A.82C.html

01/23 17:14, , 1F
錯好多地方,你要不要重寫一次....
01/23 17:14, 1F
不知道大大可以指導一下嗎^^" ※ 編輯: oklp1415 (118.171.38.31), 01/23/2015 22:42:25

01/24 08:36, , 2F
select name.age from personnel
01/24 08:36, 2F

01/24 08:37, , 3F
where salary>45000 and department =
01/24 08:37, 3F

01/24 08:38, , 4F
(select department from personnel where
01/24 08:38, 4F

01/24 08:38, , 5F
salary > 40000 group by department
01/24 08:38, 5F

01/24 08:38, , 6F
having count(department);
01/24 08:38, 6F
這樣還是有爆錯的情況 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

01/29 10:31, , 7F
你的having後面沒有條件式,還有子查詢最後少個)
01/29 10:31, 7F
文章代碼(AID): #1KmWYqWi (Database)
文章代碼(AID): #1KmWYqWi (Database)