Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1082523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:18:45+00:00 2026-05-16T22:18:45+00:00

Let’s say I have two tables: Table 1 has the columns NOTE_ID (a unique

  • 0

Let’s say I have two tables:

Table 1 has the columns NOTE_ID (a unique key) and NOTE_BODY (a big text blurb).

Table 2 has the columns KEYWORD_ID (a unique key) and KEYWORD (a keyword).

I want to get a result set that tells me which keywords each NOTE_BODY contains, without nesting a bunch of loops. So ideally I would get a row for each NOTE_BODY-KEYWORD match.

What’s the right way to go about this? I’m unsure if a JOIN+LIKE’%%’ does the trick, or if I should be using full-text indexing. Any help much appreciated…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:18:46+00:00Added an answer on May 16, 2026 at 10:18 pm

    A full text indexing solution is the right way to do this, if you plan to have many rows. You could use MySQL’s native solution if you are using the MyISAM storage engine, but you could also consider the popular third-party search engines Sphinx and Apache Lucene.

    On the other hand, a simple INNER JOIN would have done the trick:

    SELECT  t1.note_id, t1.note_body, t2.keyword
    FROM    table_1 t1
    JOIN    table_2 t2 ON (t1.note_body LIKE CONCAT('%', t2.keyword, '%'));
    

    Test case:

    CREATE TABLE table_1 (note_id int, note_body varchar(100));
    CREATE TABLE table_2 (keyword_id int, keyword varchar(50));
    
    INSERT INTO table_1 VALUES (1, 'Hello Stack Overflow');
    INSERT INTO table_1 VALUES (2, 'Hello World');
    INSERT INTO table_1 VALUES (3, 'Hello, my name is Daniel');
    INSERT INTO table_1 VALUES (4, 'Goodbye');
    
    INSERT INTO table_2 VALUES (1, 'Hello');
    INSERT INTO table_2 VALUES (2, 'name');
    

    Result:

    +---------+--------------------------+---------+
    | note_id | note_body                | keyword |
    +---------+--------------------------+---------+
    |       1 | Hello Stack Overflow     | Hello   |
    |       2 | Hello World              | Hello   |
    |       3 | Hello, my name is Daniel | Hello   |
    |       3 | Hello, my name is Daniel | name    |
    +---------+--------------------------+---------+
    4 rows in set (0.00 sec)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.