这是我试图执行的代码。
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()
答案 0 :(得分: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;
答案 1 :(得分:-1)
声明中有多个错误
1)
SELECT * Catagory FROM Catagory
Shloud be
SELECT * FROM Catagory
或
SELECT Catagory FROM Catagory
2)
LEFT JOIN products.Price ON Catagory.Category=products.Price
您不能使用它,因为这些链接中的数据不相同。 对于前者您可以链接两列具有数字或列的名称但不能将数字链接到名称的列。
第二个不是错误,它更像是错误的做法