SQL WHERE string LIKE field

雨燕双飞 提交于 2019-12-11 07:37:00

问题


I have a table tracking links structured as follows:

id
domain_name
traffic_count
enabled
created_at

Let's say I have a record with domain_name of "some-domain.com", and then let's say I want to find the record having that domain, except all I have to go by is a subdomain of that domain.

I essentially want to do this:

SELECT * FROM links 'subdomain.some-domain.com' LIKE %domain_name%"

How would I do this?


回答1:


Updated (thanks to Chad Johnson):

SELECT * FROM links WHERE 'subdomain.some-domain.com' LIKE CONCAT('%', domain_name, '%')


来源:https://stackoverflow.com/questions/9523829/sql-where-string-like-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!