我是靠谱客的博主 要减肥可乐,这篇文章主要介绍mysql中and和like一块使用,在MySQL中将LIKE%..%与字段值一起使用,现在分享给大家,希望可以做个参考。

I stumbled into a delicate SQL problem when I needed to use a value from a field inside a LIKE %..% statement.

Example:

SELECT t1.Notes, t2.Name

FROM Table1 t1, Table2 t2

WHERE t1.Notes LIKE '%t2.Name%'

This is only an example from the top of my head to show what I need to do (I know this will not work). I need to use the value of t2.Name inside the LIKE %..%

I guess this is trivial when you know it ;)

解决方案

Use:

SELECT t1.Notes,

t2.Name

FROM Table1 t1

JOIN Table2 t2 ON t1.Notes LIKE CONCAT('%', t2.Name ,'%')

最后

以上就是要减肥可乐最近收集整理的关于mysql中and和like一块使用,在MySQL中将LIKE%..%与字段值一起使用的全部内容,更多相关mysql中and和like一块使用,在MySQL中将LIKE%内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(48)

评论列表共有 0 条评论

立即
投稿
返回
顶部