Like join query

Source: Internet
Author: User

For example, there are two phases in table 1 and table 2, and you want to use like for join queries // use concat to connect the string select t1.id, t1.title, t2.keyword from t1 inner join t2 on t1.title like concat ('%', t2.keyword, '% ');
// Oracle, s use | connection string. If other databases use string connection, select t1.id, t1.title, t2.keyword from t1 inner join t2 on t1.title like '%' | t2.keyword | '% ';
Other ideas: Exists (exists), regexp (regular), instr (string inclusion)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 Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.