2017-10-09 81 views
0

這是我正在執行的代碼。嘗試執行SQL查詢時出現三重錯誤

SELECT * Catagory 
FROM Catagory 
LEFT JOIN products.Price 
ON Catagory.Category=products.Price 
WHERE ((Catagory.Category='Ring' OR Catagory.Category='Earings') AND(products.Price<=30)) 
ORDER BY products.Price 

我不確定是否這是我試圖進行連接或可能需要重置權限的事實。

該代碼似乎在數據庫中使用其他表時工作,我敢肯定,這一個具有所有相同的設置。

SELECT * Catagory 
FROM Catagory 
LEFT JOIN products.Price 
ON Catagory.Category=products.Price 
WHERE ((Catagory.Category='Ring' OR Catagory.Category='Earings') AND(products.Price<=30)) 
ORDER BY products.Price LIMIT 0, 25 
MySQL said: Documentation 

#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 'Catagory 
FROM Catagory 
LEFT JOIN products.Price 
ON Catagory.Category=products' at line 1 

Warning in ./libraries/DbQbe.php#1669 
array_map() expects parameter 1 to be a valid callback, class 'Util' not found 

Backtrace 

./libraries/DbQbe.php#1669: array_map(
string 'Util::backquote', 
array, 
) 
./libraries/DbQbe.php#1556: PMA\libraries\DbQbe->_getJoinForFromClause(array, 
array, 
) 
./libraries/DbQbe.php#1789: PMA\libraries\DbQbe->_getFromClause(array) 
./libraries/DbQbe.php#1857: PMA\libraries\DbQbe->_getSQLQuery(array) 
./db_qbe.php#153: PMA\libraries\DbQbe->getSelectionForm() 


Warning in ./libraries/DbQbe.php#1670 
implode(): Invalid arguments passed 

Backtrace 

./libraries/DbQbe.php#1670: implode(
string ', ', 
NULL, 
) 
./libraries/DbQbe.php#1556: PMA\libraries\DbQbe->_getJoinForFromClause(
array, 
array, 
) 
./libraries/DbQbe.php#1789: PMA\libraries\DbQbe->_getFromClause(array) 
./libraries/DbQbe.php#1857: PMA\libraries\DbQbe->_getSQLQuery(array) 
./db_qbe.php#153: PMA\libraries\DbQbe->getSelectionForm() 
+1

'SELECT * FROM產品類別Catagory'應該說是'SELECT * FROM Category'? – JanR

+0

兩個表都在同一個數據庫中嗎? –

+1

而且......你確定你想在'Category'(一個字符串)上等於'Price'(一個數字)的兩個表嗎? – mauro

回答

-1

你必須在聲明中

1)多錯

SELECT * Catagory FROM Catagory 

Shloud是

SELECT * FROM Catagory 

SELECT Catagory FROM Catagory 

2)

LEFT JOIN products.Price ON Catagory.Category=products.Price 

不能使用本作中,這些鏈接中的數據是不一樣的。 例如。您可以鏈接兩列有數字或兩列的名稱,但不能將數字鏈接到名稱。

第二個是不是一個錯誤它更像是一個做錯了

0

您所查詢的是錯了,它應該像

SELECT * 
FROM Catagory c 
LEFT JOIN products p 
ON c.Category=p.Price 
WHERE ((c.Category='Ring' OR c.Category='Earings') AND(p.Price<=30)) 
ORDER BY p.Price; 
相關問題