2014-09-25 67 views
-1

嘿傢伙,我已經嘗試了MySQL的嵌套查詢這就好比在phpMyAdmin使用嵌套查詢錯誤

SELECT test.babe,test.some 
FROM (
SELECT 'password' AS babe 

) test 

它做工精細

但是,當我試圖

SELECT babe,some 
FROM (
SELECT 'password' AS babe 
SELECT 'username' AS some 
) test 

它拋出錯誤像

#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 'SELECT 'username' AS some) test' at line 5 

對於mysql來說是新的。希望你們能幫助我..

+0

如果您是新的SQL,你會發現,讀一本書或教程學習它比要求StackOverflow上的問題的更有效的方式。嘗試http://sqlzoo.net/ – 2014-09-25 16:58:00

回答

1

你可以把它改寫爲

SELECT babe, some 
    FROM (
    SELECT 'password' AS babe, 'username' AS some 
    ) test 
+1

whoaaaa..works喜歡魅力.. – 2014-09-25 16:57:04

+0

你能告訴我我怎麼可以在裏面添加值?我試過 – 2014-09-25 17:14:18

+0

INSERT INTO test(babe,some) VALUES ('sdada','adasd');它會拋出語法錯誤 – 2014-09-25 17:16:40