开发者

How to use select result with like in MySQL

开发者 https://www.devze.com 2023-01-21 08:45 出处:网络
I need some MySQL code that uses a select output in LIKE statement in WHERE. I mean something like开发者_开发技巧 this:

I need some MySQL code that uses a select output in LIKE statement in WHERE.

I mean something like开发者_开发技巧 this:

SELECT id FROM (SELECT id,parent_id FROM units WHERE ptitle 
like '%(SELECT ptitle FROM units WHERE id='".$id."')%')


you need to use concat

SELECT id FROM (

SELECT id,parent_id FROM units WHERE ptitle

like concat('%',(SELECT ptitle FROM units WHERE id='".$id."'), '%')

) sub_table
0

精彩评论

暂无评论...
验证码 换一张
取 消