我有这个错误LOG.error: SQLSTATE42000:语法错误或访问冲突: 1066,不是唯一的表/别名:'products‘。有sql:
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的错误。
发布于 2022-11-10 11:45:21
SQL语句中指定的每个表都需要一个唯一的别名。您可以不止一次地加入同一个表,但是如果您这样做了,则必须为该表的每个实例提供不同的别名。
你似乎不止一次地加入了“产品”桌。您需要使用类似于JOIN products AS products2的内容,并在SQL条件中使用这个products2引用。
https://stackoverflow.com/questions/74388389
复制相似问题