2011-06-10 49 views
0

我用了一個查詢像MySQL錯誤內加入

select a.email,b.vuid 
from user a 
,inner join group b on a.uid = b.uid 
where a.email='[email protected]' and a.kid=1 and b.vid=29 
limit 1 

,但我總是得到這個錯誤。

您的SQL語法錯誤;檢查對應於你的MySQL服務器版本附近使用正確的語法手冊「內參加B組的a.uid = b.uid其中a.email='[email protected]」在行1

我認爲它是因爲內部連接,但我不知道真的..有人可以幫助我嗎?

回答

4

from user a之後刪除,

您的查詢應該是:

select a.email,b.vuid 
from user a 
inner join group b 
on a.uid = b.uid 
where a.email='[email protected]' 
    and a.kid=1 
    and b.vid=29 
limit 1 
+0

非常感謝! – Roby 2011-06-10 17:49:45

2
select a.email,b.vuid from user as a inner join group as b on ... 

當然,你可以省略這表現在@FrustratedWithFormsDesigner但在我看來,這是更具可讀性這種方式as關鍵字。

+0

-1,這是一個語法錯誤 – Johan 2011-06-10 17:48:18

+0

@Johan感謝評論,你能告訴我語法錯誤嗎? – kapa 2011-06-10 17:50:05

+0

你在'內部連接'之前有一個',' – Johan 2011-06-10 18:04:03