gpt4 book ai didi

mySql 查询给我语法错误

转载 作者:行者123 更新时间:2023-11-29 11:05:22 24 4
gpt4 key购买 nike

在 phpMyAdmin 中给我这个错误:

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 'table ON brand.seo_name = table.brandName ORDER BY b' at line 8

这是查询:

SELECT brand.name, brand.seo_name
FROM brand
JOIN (
SELECT IFNULL(product.brand, standard_product.brand) AS brandName
FROM product
JOIN standard_product
ON product.standard_product_id = standard_product.id
WHERE product.store_id = 1) AS table
ON brand.seo_name = table.brandName

ORDER BY brand.seo_name ASC
LIMIT 0,30

最佳答案

table 是保留字。您应该选择不同的别名,例如t:

SELECT brand.name, brand.seo_name
FROM brand
JOIN (
SELECT IFNULL(product.brand, standard_product.brand) AS brandName
FROM product
JOIN standard_product
ON product.standard_product_id = standard_product.id
WHERE product.store_id = 1) t
ON brand.seo_name = t.brandName
ORDER BY brand.seo_name ASC
LIMIT 0,30

关于mySql 查询给我语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41488268/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com