gpt4 book ai didi

mysql - 如何通过%列名%获取Mysql数据

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

这个概念是为了匹配用户关系并从时间线表中获取帖子

表:时间线 {id,title,privacyTimeline}表:friend_request{id,requestType,status,from_id,to_id}

我正在尝试获取隐私和 requestType 匹配的位置,但有用逗号分隔的值隐私时间线 = '家人、 friend 'requestType ='家庭'

我已经编写了此查询,但无法使用 like'%%'

SELECT t.id,t.title
FROM timeline t JOIN
friend_request fr
WHERE (fr.from_id = '3' OR fr.to_id='3') AND
(t.privacyTimeline LIKE '%f.requestType%')

不起作用

但当我将列名 fr.requestType 替换为简单文本“family”时,它就起作用了从时间线中选择 t.id,t.title as t JOINfriend_request as fr WHERE(fr.from_id = '3' OR fr.to_id='3') AND(t.privacyTimeline LIKE '%family%')

请任何可以指导我的人

最佳答案

使用string concatenation :

t.privacyTimeline LIKE CONCAT('%', f.requestType, '%')

关于mysql - 如何通过%列名%获取Mysql数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32765258/

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