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 8537117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:49:17+00:00 2026-06-11T10:49:17+00:00

i am doing a table with multiple keyboards or tags, like this: id |

  • 0

i am doing a table with multiple keyboards or tags,
like this:

id |   keyboards
===+================================================
1  |     picture,mountain,animals 
2  |     water,mountain
3  |     sound, mountain
4  |     water, picture, mountain, space, other

and i want to make a select.

SELECT id from table where (mountain,picture,space) in keyboards;

result must be:
1 row

id

4.

please help me.

  • 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-06-11T10:49:18+00:00Added an answer on June 11, 2026 at 10:49 am

    You have poor database normalization. Best way to do is to create a table Keyboards

    CREATE TABLE Keyboards
    (
        Keyboard_ID INT AUTO_INCREMENT,
        KeyBoardName VARCHAR(25),
        CONSTRAINT kbrd_pk PRIMARY KEY (Keyboard_ID),
        CONSTRAINT kbrd_uq UNIQUE(KeyboardName)
    )
    
    CREATE table Tags
    (
        ID INT AUTO_INCREMENT,
        Keyboard_ID int,
        CONSTRAINT tags_pk PRIMARY KEY (ID),
        CONSTRAINT tags_pk FOREIGN KEY (keyboard_ID) REFERENCES keyboards(keyboard_ID)
    )
    

    then reference keyboards.id in tags table.

    Then you can do this query,

    SELECT id,
    FROM   tags a
           INNER JOIN keyboards b
               ON a.keyboard_id = b.keyboard_ID
    WHERE  b.keyboardName IN ('mountain','picture','space')
    GROUP BY ID
    HAVING COUNT(DISTINCT b.keyboardName) = 3
    

    but to answer you question, you can simply do this

    select *
    from tags
    where keyboards like concat('%','mountain','%') AND
          keyboards like concat('%','picture','%') and
          keyboards like concat('%','space','%')
    

    SQLFiddle Demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am talking about doing something like this: LOCK TABLE page WRITE; SELECT *
I have a table like this id, name, datetime which might store multiple entries
I'm doing a table import using a multiple INSERT (INSERT INTO ... VALUES (1),
How can i insert multiple values in a sql table using single statement. Doing
I have a table view. And I have multiple rows. While doing the reorder
I'm trying to update multiple rows in one table in MySQL database by doing
I just want to simplify what I am doing before, having multiple php files
I am doing a table join on a mysql databse. I want the results
i have a table name preferences under this there are multiple columns but i
I have a product table with a tag column, each product has multiple tags

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.