Home > Database > Mysql Tutorial > Like关联查询

Like关联查询

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:56:27
Original
1606 people have browsed it

例如:有表1,表2两张相,希望通过like进行关联查询// mysql中使用concat连接字符串select t1.id, t1.title, t2.keyword from t1 inner join t2 on t1.title like concat('%', t2.keyword, '%'); // oracle、postgres 使用||连接字符串,其它库使用字符串连方

例如:有表1,表2两张相,希望通过like进行关联查询 // mysql中使用concat连接字符串 select t1.id, t1.title, t2.keyword from t1 inner join t2 on t1.title like concat('%', t2.keyword, '%');
// oracle、postgres 使用||连接字符串,其它库使用字符串连方式连接即可 select t1.id, t1.title, t2.keyword from t1 inner join t2 on t1.title like '%' || t2.keyword || '%';
其它思路:exists(是否存在)、regexp(正则)、instr(字符串包含) select distinct t1.title from t1 , t2 where instr(t1.title,t2.keyword); select distinct t1.title from t1 inner join t2 on t1.title regexp t2.keyword; select * from t1 where exists (select keyword from t2 where t1.title regexp keyword); select * from t1 where exists (select keyword from t2 where t1.title like concat('%',keyword,'%'));
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Django's LIKE operation.
From 1970-01-01 08:00:00
0
0
0
Isn’t this iQiyi-like course finished? ?
From 1970-01-01 08:00:00
0
0
0
javascript - js cannot retrieve objects like this
From 1970-01-01 08:00:00
0
0
0
Why should I write it like this?
From 1970-01-01 08:00:00
0
0
0
How to open a developer tool like yours
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template