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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:23:34+00:00 2026-06-17T23:23:34+00:00

i have a search query that i need to modify and adapt into a

  • 0

i have a search query that i need to modify and adapt into a custom profile system we have, that system use the following table:

  profile_key | profile_value        | user_id
       1      |    test1             |  10
       2      |    test2             |  10
       3      |    ["test3","test4"] |  10

i need to add to the where clause something that would match all the rows (depending of what the user defined in the search form) to get the user_id, something like:

 select user_id from table where (profile_key = 1 && profile_value regexp 'test1') && (profile_key = 3 && profile_value regexp 'test4')

i need to get all the user_id IF it matched all the defined profile_key and the regexp.

any idea how i can accomplish this?

Regards.

  • 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-17T23:23:35+00:00Added an answer on June 17, 2026 at 11:23 pm

    The simplest way would be to use EXISTS:

    SELECT user_id
    FROM users
    WHERE EXISTS (SELECT 1 FROM profiles WHERE profile_key = 1 
        AND profile_value regexp 'test1' AND profiles.user_id = users.user_id)
    AND EXISTS (SELECT 1 FROM profiles WHERE profile_key = 3 
        AND profile_value regexp 'test4' AND profiles.user_id = users.user_id)
    

    You could also accomplish this with an INNER JOIN, once for each row you want to match:

    SELECT user_id
    FROM users
    INNER JOIN profiles p1 ON users.user_id = p1.user_id
    INNER JOIN profiles p2 ON users.user_id = p2.user_id
    WHERE p1.profile_key = 1 AND p1.profile_value regexp 'test1'
    AND p2.profile_key = 3 AND p2.profile_value regexp 'test4'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have table with ten field . i need search query in LINQ that
I have a search query that works great, but I need it to only
I have the following search query (need to have the year/month and slug of
I have a T-SQL query as below which queries a table holding the search
I have search query that has many optional parameters and then search word field
Im trying to query the Netflix OData feed. I have the following query that
I need to write a query that will perform a keyword search on a
I have a query that produces the following output in a nested set structure:
I have a simple MySQL query that selects all columns from the table based
I have a query that will need to run 28 000 times in a

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.