2012-05-03 42 views
1

我是新來的mysql,請善待。我得到了我的腳本以下錯誤,我不知道它有什麼問題。mysql intersect

SELECT uoid 
FROM mint 
WHERE mint_id='6' and userid='3836' 
INTERSECT 
SELECT id as uoid 
FROM cats 
WHERE category='Health, Fitness' 
ORDER BY 1; 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTERSECT SELECT id as uoid FROM cats WHERE category='Health, Fitness'' at line 4 
+1

這是因爲MySql沒有INTERSECT關鍵字。可能有趣:http://stackoverflow.com/questions/2621382/intersect-in-mysql。 – alexn

+1

...和這一個:http://stackoverflow.com/q/2300322/306084 – pjmorse

回答

6

MySQL沒有INTERSECT關鍵字。請參閱this questionthis one,以獲取有關如何實現目標的建議。

+0

謝謝!我會給你,因爲你給的鏈接幫助解決了我的問題 – John

+0

+1,但它有沒有可能呢? :O :( – Revious

1

INTERSECT在MySQL不支持。你需要以某種方式重組你的查詢。如果您的MySQL版本支持子查詢,您可能可以使用子查詢。

0

這是因爲只在相同的表格上相交,而不是在您嘗試的表格上。 請參閱this

代替交叉使用聯接語句語法。 而INTERSECT確實存在於sql