Mysql:连接查询中的限制

Mysql:连接查询中的限制,mysql,Mysql,这是我对“选择所有收藏”以及“图像名称”的查询 SELECT cushbu_art.image_name, cushbu_user_collections.collection_name FROM cushbu_art JOIN cushbu_art_collections ON cushbu_art.id = cushbu_art_collections.art_id LEFT JOIN cushbu_user_collections ON cushbu_user_c

这是我对“选择所有收藏”以及“图像名称”的查询

 SELECT
    cushbu_art.image_name,
    cushbu_user_collections.collection_name
FROM
    cushbu_art
JOIN cushbu_art_collections ON cushbu_art.id = cushbu_art_collections.art_id
LEFT JOIN cushbu_user_collections ON cushbu_user_collections.id = cushbu_art_collections.collection_id
现在我只想从
cushbu\u art
表中选择3行(即需要在此
JOIN cushbu\u art\u collections on cushbu\u art.id=cushbu\u art\u collections.art\u id
上应用限制)

我从这个问题中找到了一个解决方案,但我无法从中理解这个解决方案

更新

当前查询返回此

collection_name image_name

test-collection  test1.jpg
test-collection  test2.jpg
test-collection  test3.jpg
hello-collection hello.jpg
集合名称
测试集合
重复三次,因为子表(cushbu_艺术)包含一个集合的三个图像 所以我想对cushbu\u艺术图像\u名称

预期产量

    collection_name image_name

    test-collection  test1.jpg
    test-collection  test2.jpg
    hello-collection hello.jpg
这是我最新的问题

SELECT
    cushbu_art.image_name,
    cushbu_user_collections.collection_name
FROM
    cushbu_art
JOIN cushbu_art_collections ON cushbu_art.id =(
    SELECT
        id
    FROM
        cushbu_art
    WHERE
        cushbu_art.id = cushbu_art_collections.art_id
    LIMIT 1
)
LEFT JOIN cushbu_user_collections ON cushbu_user_collections.id = cushbu_art_collections.collection_id

你应该给mysql一个帮助,把cushbu_art_Collections的名字改成别名。我不明白你的意思。真的吗?这个问题的投票结果没有任何示例数据吗?@RaymondNijland用预期输出更新了我的问题。在你的预期输出中,为什么有两个图像名称(test1.jpg,test2.jpg)每一个集合名称测试集合?你应该给mysql一个帮助之手,将cushbu_art_集合化名。我不明白你的意思。真的吗?这个问题在没有任何示例数据和预期结果的情况下被投票了吗?@RaymondNijland用预期输出更新了我的问题。在你的预期输出中,为什么有两个图像名称(test1.jpg,test2.jpg)每个集合名测试集合?