gpt4 book ai didi

mysql - 查询返回错误的输出

转载 作者:行者123 更新时间:2023-11-29 05:34:53 25 4
gpt4 key购买 nike

餐 table 报价

id_offer  offer   state    

600 A 0
629 B 0

标签

id_tags     tags        

561 PHP
562 JAVA
589 MySQL
917 python

offer_has_tags

offer_id_offer      tags_id_tags 
600 561
600 562
600 917
629 562
629 589
629 917

我需要的输出:

600     PHP
600 JAVA
600 python
629 JAVA
629 MySQL
629 python

我正在尝试的(没有成功):

    SELECT A.id_offer, A.tags
FROM
( SELECT *
FROM offer
WHERE id_offer IN (600, 629)
AND state = 0
ORDER BY date_post DESC
LIMIT ?, ?
) A, tags A
INNER JOIN offer_has_tags B
ON A.id_tags = B.tags_id_tags
INNER JOIN offer C
ON C.id_offer = B.offer_id_offer
GROUP BY id_tags

有什么想法吗?谢谢

最佳答案

试试这个

SELECT A.id_offer, t.tags
from
(Select * from offer o
Where o.id_offer IN (600, 629)
AND o.State=0
ORDER BY ? DESC
Limit ?,?) A
INNER JOIN offer_has_tags B
ON A.id_offer = B.offer_id_offer
INNER JOIN tags t
ON b.tags_id_tags = t.id_tags

关于mysql - 查询返回错误的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11596987/

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