gpt4 book ai didi

mysql - Sql查询问题从sql查询中找出表名

转载 作者:行者123 更新时间:2023-11-29 16:03:11 26 4
gpt4 key购买 nike

我正在测试我的一个项目,它是 opencart

基本上我想确定我的表名,例如 oc20_product 和 oc20_manufacturer 是表名不是吗?这是其他实际的列吗?

我的表和列的名称到底是什么?

提前致谢

注意:

Error: 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 '%' AND p.status = 1 GROUP BY m.manufacturer_id ORDER BY m.name ASC' at line 4 Error No: 1064

SELECT m.manufacturer_id, m.name, COUNT(p.product_id) AS products_total 
FROM oc20_product p
LEFT JOIN oc20_product_description pd
ON pd.product_id = p.product_id
LEFT JOIN oc20_manufacturer m
ON m.manufacturer_id = p.manufacturer_id
WHERE pd.name LIKE '%mycard'%' AND p.status = 1
GROUP BY m.manufacturer_id
ORDER BY m.name ASC in

最佳答案

类似模式中的引用错误,您可以使用 concat 来实现简单的模式格式

SELECT m.manufacturer_id
, m.name
, COUNT(p.product_id) AS products_total
FROM oc20_product p
LEFT JOIN oc20_product_description pd ON pd.product_id = p.product_id
LEFT JOIN oc20_manufacturer m ON m.manufacturer_id = p.manufacturer_id
WHERE pd.name LIKE concat('%',mycard,'%') AND p.status = 1
GROUP BY m.manufacturer_id, m.name
ORDER BY m.name ASC

关于mysql - Sql查询问题从sql查询中找出表名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55981357/

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