mysql基础 Like关联查询

1// mysql中使用concat连接字符串 2select t1.id, t1.title, t2.keyword from t1 inner join t2 on t1.title like concat('%', t2.keyword, '%'); 3 4 5其它思路:exists(是否存在)、regexp(正则)、instr(字符串包含) 6select distinct t1.title from t1 , t2 where instr(t1.title,t2.keyword); 7select distinct t1.title from t1 inner join  t2 on t1.title regexp t2.keyword; 8select * from t1 where exists (select keyword from t2 where t1.title regexp keyword); 9select * from t1 where exists (select keyword from t2 where t1.title like concat('%',keyword,'%'));

https://blog.csdn.net/bbirdsky/article/details/26054971

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

MySQL基础(一)

一、连接MySQL数据库1连接:2mysqlhhostuuserp34常见错误:5ERROR2002(HY000):Can'tconnecttolocalMySQLserverthroughsocket'/tmp/my

SQOOP导入mysql数据库乱码

一、mysql中的编码mysql show variables like 'collation_%';| Variable_name | Value |

MYSQL正则表达式

MySQL中使用REGEXP操作符来进行正则表达式匹配。下表中的正则模式可应用于REGEXP操作符中。模式描述^匹配输入字符串的开始位置。如果设置了RegExp对象的Multiline属性,^也匹配'\\n'或'\\r'之后的位置。$匹配输入字符串的结束位置。如果设置了RegExp对象的Mul

MySQL中group_concat函数,用符号连接查询分组里字段值

MySQL中group\_concat函数完整的语法如下:group\_concat(\DISTINCT\要连接的字段\OrderBYASC/DESC排序字段\\Separator'分隔符'\)基本查询\sql\ viewplain(https://www.oschina.net/act

SQOOP导入mysql数据库乱码

一、mysql中的编码mysql show variables like 'collation_%';| Variable_name | Value |