如何检查字符串是否包含 MySQL 中某一列的任何字符串,反之亦然? [英] How to check if a string contains any string of a column in MySQL and vice versa?

查看:67
本文介绍了如何检查字符串是否包含 MySQL 中某一列的任何字符串,反之亦然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反之亦然,我的意思是,检查列中是否有任何字符串包含该字符串.

By vice versa, I mean, check if any of the strings in a column contains the string.

示例:

字符串 a = "意大利辣香肠"

String a = "Peperoni"

MySQL 列:

{
    "PPeperoni_123",
    "roni",
    "hello world"
}

它应该返回前 2 行.

It should return the first 2 rows.

(注意:我正在为此寻找查询字符串)

(Note: im looking for the query string for this)

推荐答案

不确定我是否理解正确,但您是否正在寻找这个:

Not sure if I understand you correctly, but are you maybe looking for this:

SELECT ... WHERE column LIKE "%string%" OR string LIKE CONCAT("%", column, "%")

这篇关于如何检查字符串是否包含 MySQL 中某一列的任何字符串,反之亦然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆