简体   繁体   中英

SQL WHERE string LIKE field

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?

更新(感谢乍得·约翰逊):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM