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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:26:05+00:00 2026-06-03T09:26:05+00:00

I have MySQL database with two tables: users and items. They look like this:

  • 0

I have MySQL database with two tables: users and items. They look like this:

users:

id | user_name | desc
--------------------------
1  | john      | tall
2  | dave      | fat
3  | maria     | pretty

items:

id | item_name | color
--------------------------
1  | trousers  | red
2  | shoes     | blue
3  | shoes     | red

I want to select from database list of items that have specific id and name of it is LIKE a keyword. It’s for use of simple search engine.
I am making such query:

SELECT id, user_name, ( SELECT item_name FROM items WHERE id = u.id ) as desc FROM users u WHERE desc LIKE "%shoes%" AND color LIKE "%blue%"

As a result, I would expect one line containing id = 2, username = dave and itemname = shoes because it’s the only one row fulfilling my query. Unfortunately, I get a message that there is no a ‘desc’ column. I know that there is not such a column in ‘users’ but how tell MySQL to grab it from subquery named desc?

Additional question: is that possible to work with WHERE … LIKE command and array style like IN (val1, val2, val3)? I mean instead of loooong queries:

SELECT name 
FROM users 
WHERE name 
LIKE "%john%" OR name 
LIKE "%steven%" OR name LIKE "bob%"

make shorter:

SELECT name FROM users WHERE name LIKE IN ( "%john%", "%steven%", "%bob%")

Thanks in advance.

  • 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-03T09:26:06+00:00Added an answer on June 3, 2026 at 9:26 am

    Try this :

    SELECT 
        u.id, u.user_name, i.item_name, i.color
    FROM
        users AS u,
        items AS i
    WHERE
        i.id = u.id
    AND
        i.item_name LIKE "%shoes%" 
    AND 
        i.color LIKE "%blue%"
    

    For the second part, if you look at this page on MySQL dev site you will see that you can use REGEXP to match your result instead of LIKE so you I think you can use something like

    REGEXP 'john|steven|bob'

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

Sidebar

Related Questions

I have a mysql database with two tables, bookings and users. They are linked
I have two tables in my MySQL database, users and tweets, as follows: TABLE
In a MySQL database I have two tables linked in a join. One table
I have two tables in a MySql database: COUNTRY --------------- id, country_name and CITY
I am working on PHP and database MySQL. I have two tables in SQL
I have 10 tables in my database(MySQL). two of them is given below tbl_state
I have two tables in mysql database groups id|name _______ 1 |red 2 |blue
I have a database where users are presented with two items and choose the
I have two tables in my MySQL database (table1 and table 2). I want
I have a mysql database with two tables: table1 (id, name, emailid) table2 (id,

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.