简体   繁体   English

SQL WHERE字符串LIKE字段

[英]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. 假设我有一个domain_name为“ some-domain.com”的记录,然后说我想查找具有该域的记录,只是我需要经过的只是该域的子域。

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, '%')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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