热线电话:13121318867

登录
2021-04-07 阅读量: 899
SQL怎么用列和另一列匹配,但是是模糊匹配?

问:

SQL怎么用列和另一列匹配,但是是模糊匹配?

答:

将两表进行连接后在where子句中使用模糊匹配,例如A表中的proj_dept字段包含了多个B表中的,用逗号分隔的dept_id,如果要实现A表和B表的关联可以执行以下代码:

select * from A,B

where concat(',',A.proj_dept,',') like concat('%,',cast(B.dept_id as char),',%')

order by proj_dept,dept_id;


240.0000
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子