gpt4 book ai didi

mysql - #1066 - 错误不是唯一的表别名

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

我正在学习 mysql,我的一个表遇到了问题,它产生了 #1066 - 错误不是唯一的表别名。我尝试了许多不同的查询,但都有相同的结果。有人可以让我摆脱痛苦并帮助指出我做错了什么吗! - 谢谢

表格

looks
---------

look_id(Pk)
user_id
title
description
date_modified

Add_Look_Item
-----------------------

look_id (fk from table 1)
item_id (fk from table 3)

Item
--------------

item_id (pk)
name
details

Add_Images
-------------------
image_id (pk)
item_id (fk from table 3)
image_name

我尝试过的查询 - add_look_item 是复合键

SELECT DISTINCT looks.look_id, looks.title, looks.date_modified, add_look_item.item_id,     add_images.image_name FROM looks JOIN add_look_item ON add_look_item.look_id = looks.look_id
JOIN add_look_item ON add_look_item.item_id = item.item_id WHERE look.user_id = 94

#1066 - error not unique table alias 'add_look_item

SELECT DISTINCT looks.look_id, looks.title, looks.date_modified, add_look_item.item_id, add_images.image_name FROM looks JOIN
add_look_item ON add_look_item.looks_id = look.look_id
JOIN add_look_item ON add_look_item.item_id = item.item_id
JOIN add_images ON add_images.item_id = item.item_id WHERE add_look_item.item_id = item.item_id AND look.user_id = 94

#1066 - error not unique table alias 'add_look_item

SELECT DISTINCT looks.look_id, looks.title, looks.date_modified, add_look_item.item_id, add_images.image_name FROM looks INNER JOIN add_look_item ON add_look_item.look_id = look_look_id
INNER JOIN add_images ON add_images.item_id = item.item_id
INNER JOIN add_look_item ON add_look_item.item_id = item.item_id
WHERE look.user_id = 94

#1066 - error not unique table alias 'add_look_item

SELECT DISTINCT looks.look_id, looks.title, looks.date_modified, add_look_item.item_id, add_images.image_name FROM looks
INNER JOIN add_look_item ON add_look_item.looks_id = look.look_id
INNER JOIN add_images ON add_images.item_id = item.item_id
INNER JOIN add_look_item ON add_look_item.item_id = item.item_id
WHERE add_look_item.item_id = item.item_id AND look.user_id = 94


#1066 - error not unique table alias 'add_look_item

SELECT DISTINCT looks.look_id, looks.title, looks.date_modified, add_look_item.item_id, add_images.image_name FROM looks
INNER JOIN add_look_item ON add_look_item.looks_id = look.look_id
INNER JOIN add_images ON add_images.item_id = item.item_id
WHERE add_look_item.item_id = item.item_id AND look.user_id = 94

#1054 - Unknown column 'item.item_id' in 'where clause'

谢谢

最佳答案

试试这个 -

SELECT looks.look_id, looks.title, looks.date_modified, add_look_item.item_id, add_images.image_name
FROM looks
JOIN add_look_item
ON looks.look_id = add_look_item.look_id
JOIN add_images
ON add_look_item.item_id = add_images.item_id
WHERE look.user_id = 94

关于mysql - #1066 - 错误不是唯一的表别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10041954/

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