首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LOG.error: SQLSTATE[42000]:语法错误或访问冲突: 1066非唯一表/别名:“产品”

LOG.error: SQLSTATE[42000]:语法错误或访问冲突: 1066非唯一表/别名:“产品”
EN

Stack Overflow用户
提问于 2022-11-10 11:38:28
回答 1查看 26关注 0票数 0

我有这个错误LOG.error: SQLSTATE42000:语法错误或访问冲突: 1066,不是唯一的表/别名:'products‘。有sql:

代码语言:javascript
复制
select distinct `seller_products`.* from `seller_products` inner join `products` on `products`.`id` = `seller_products`.`product_id` and `products`.`status` = 1 inner join `products` on `seller_products`.`product_id` = `products`.`id` inner join (`category_product` inner join `categories` on `categories`.`id` = `category_product`.`category_id` and categories.id in ('4868')) on `category_product`.`product_id` = `products`.`id` where ((`seller_products`.`user_id` = 1 and exists (select * from `products` where `seller_products`.`product_id` = `products`.`id` and `products`.`status` = 1) and `seller_products`.`status` = 1 or exists (select * from `users` where `seller_products`.`user_id` = `users`.`id` and (exists (select * from `seller_accounts` where `users`.`id` = `seller_accounts`.`user_id` and (`holiday_mode` = 0 or `holiday_date` != 2022-11-10 or (`holiday_date_start` > 2022-11-10 and `holiday_date_end` < 2022-11-10 or `holiday_date_start` > 2022-11-10 or `holiday_date_end` < 2022-11-10))) and exists (select * from `seller_subcriptions` where `users`.`id` = `seller_subcriptions`.`seller_id` and `expiry_date` > 2022-11-10 and exists (select * from `users` where `seller_subcriptions`.`seller_id` = `users`.`id` and exists (select * from `seller_accounts` where `users`.`id` = `seller_accounts`.`user_id` and `seller_commission_id` = 3))) and `is_active` = 1 or exists (select * from `seller_accounts` where `users`.`id` = `seller_accounts`.`user_id` and (`seller_commission_id` != 3 and `holiday_mode` = 0 or `holiday_date` != 2022-11-10 or (`holiday_date_start` > 2022-11-10 and `holiday_date_end` < 2022-11-10 or `holiday_date_start` > 2022-11-10 or `holiday_date_end` < 2022-11-10))) and `is_active` = 1)) and `seller_products`.`status` = 1) and exists (select * from `products` where `seller_products`.`product_id` = `products`.`id` and (`products`.`id` in (6147) or `products`.`product_name` LIKE %walizka-american-tourister-linex-66-cm-deep-navy% or `products`.`description` LIKE %walizka-american-tourister-linex-66-cm-deep-navy% or `products`.`specification` LIKE %walizka-american-tourister-linex-66-cm-deep-navy%)) or `seller_products`.`product_name` LIKE %walizka-american-tourister-linex-66-cm-deep-navy%) and (`seller_products`.`user_id` = 1 and exists (select * from `products` where `seller_products`.`product_id` = `products`.`id` and `products`.`status` = 1) and `seller_products`.`status` = 1 or exists (select * from `users` where `seller_products`.`user_id` = `users`.`id` and (exists (select * from `seller_accounts` where `users`.`id` = `seller_accounts`.`user_id` and (`holiday_mode` = 0 or `holiday_date` != 2022-11-10 or (`holiday_date_start` > 2022-11-10 and `holiday_date_end` < 2022-11-10 or `holiday_date_start` > 2022-11-10 or `holiday_date_end` < 2022-11-10))) and exists (select * from `seller_subcriptions` where `users`.`id` = `seller_subcriptions`.`seller_id` and `expiry_date` > 2022-11-10 and exists (select * from `users` where `seller_subcriptions`.`seller_id` = `users`.`id` and exists (select * from `seller_accounts` where `users`.`id` = `seller_accounts`.`user_id` and `seller_commission_id` = 3))) and `is_active` = 1 or exists (select * from `seller_accounts` where `users`.`id` = `seller_accounts`.`user_id` and (`seller_commission_id` != 3 and `holiday_mode` = 0 or `holiday_date` != 2022-11-10 or (`holiday_date_start` > 2022-11-10 and `holiday_date_end` < 2022-11-10 or `holiday_date_start` > 2022-11-10 or `holiday_date_end` < 2022-11-10))) and `is_active` = 1)) and `seller_products`.`status` = 1)

有人能帮我吗?

这是来自amazCart cms的错误。

EN

回答 1

Stack Overflow用户

发布于 2022-11-10 11:45:21

SQL语句中指定的每个表都需要一个唯一的别名。您可以不止一次地加入同一个表,但是如果您这样做了,则必须为该表的每个实例提供不同的别名。

你似乎不止一次地加入了“产品”桌。您需要使用类似于JOIN products AS products2的内容,并在SQL条件中使用这个products2引用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74388389

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档