gpt4 book ai didi

sql - 仅从类型中获取一行

转载 作者:行者123 更新时间:2023-12-04 05:22:46 26 4
gpt4 key购买 nike

我有一张 table 等表日志 . 中的每一行都有很多日志票 .我想知道某个字符串是否在某个日志中,然后从 中获取一个寄存器票哪一个都没有关系,因为我只想每个 得到一行票 .这是我目前所拥有的:

SELECT ticket.id,ticket.description,ticket.owner 
FROM ticket
JOIN log
ON (log.ticketid=ticket.id)
where log.description LIKE '%someparameter%'

在这种情况下我该怎么办?

最佳答案

SELECT
*
FROM
ticket
WHERE
EXISTS (SELECT *
FROM log
WHERE log.ticketid = ticket.id
AND log.description LIKE '%someparameter%'

或者...
SELECT
ticket.id, ticket.description, ticket.owner
FROM
ticket
INNER JOIN
log
ON (log.ticketid=ticket.id)
WHERE
log.description LIKE '%someparameter%'
GROUP BY
ticket.id, ticket.description, ticket.owner

关于sql - 仅从类型中获取一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13532489/

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