gpt4 book ai didi

MySql 从冒号中选择

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

表:用户

| user_Id  | my_threads          |               
| 100 | 200:1, 201:2, 217:4 |
| 101 | 200:1, 215:3, 217:4 |

表:线程

| thread_id | author_id | title                     |
| 217 | 100 | This is title thread |
| 200 | 101 | this is only test |

当用户登录成功时$userId=user_Id,显示该用户线程的标题?

select title 
from thread
where FIND_IN_SET(thread.thread_id,(select my_threads from user where user_id=100));

当 my_threads 没有像这样的冒号 200, 217 时上面的 sql 有效

最佳答案

试试这个:

把冒号换成逗号

select title 
from thread
where FIND_IN_SET(thread.thread_id,
(select replace(replace(my_threads,':',','),' ','') from user where user_id=100))


SQL fiddle demo

关于MySql 从冒号中选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12722400/

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