我有这个查询
Select cat.Title,cat.CategoryId,count(*) as Count
from Companies,
(Select MallCategories.CategoryId, MallCategories.Title
from MallCategories
JOIN Malls ON MallCategories.MallId = Malls.MallId
WHERE Malls.MallId='5410708140ab88a90f7b23c7') AS cat
WHERE Companies.MallCategory=cat.CategoryId
GROUP BY cat.CategoryId
此查询在sqlite
数据库上正常工作,但是当我在mysql
上使用它时,它会返回此错误
Static analysis:
2 errors were found during analysis.
An expression was expected. (near "(" at position 67)
Unexpected token. (near "(" at position 67)
SQL query: Documentation
Select cat.Title,cat.CategoryId,count(*) as Count from Companies, ( LIMIT 0, 25
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 0, 25' at line 2
我做错了什么?能帮帮我吗?谢谢
Ps:这就是我所做的,它现在有效, 我把它改成了这种形式
Select cat.Title,cat.CategoryId,count(*) as Count
from
(Select MallCategories.CategoryId, MallCategories.Title
from MallCategories JOIN Malls ON MallCategories.MallId = Malls.MallId
WHERE Malls.MallId='5410708140ab88a90f7b23c7') AS cat,
Companies
WHERE Companies.MallCategory=cat.CategoryId
GROUP BY cat.CategoryId
它有效,我不知道这里发生了什么