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

  • Home
  • SEARCH
  • 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 8566627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:41:51+00:00 2026-06-11T17:41:51+00:00

This would be better to show on my example: I have table, where are

  • 0

This would be better to show on my example:

I have table, where are stored users answers from one big form. Each form has 139 questions. These questions are stored in different table, joined when needed with questionID. For each user, there is an ID. I now need to make filters, to show only users matching one or more answers on specific questions.

For example, i want users, where question 14 has answer “yes”, question 54 is not empty and question 100 is bigger than 10. This is how the table looks:

**userID** | **questionID** | **answer**

1            14               "yes"
1            54               "something"
1            100              "9"
2            14               "no"
2            54               "north
2            100              "50"
3            14               "yes"
3            54               "test"
3            100              "12"

as result i want only the userID 3 returned, because it meets all conditions.

This would be easy to reach with ColdFusion, as it allows query in queried results, but in PHP i haven’t found any way. It is important to have chance to add random number of questions, not only three as in this example.

  • 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-11T17:41:52+00:00Added an answer on June 11, 2026 at 5:41 pm

    Try,

    SELECT userID
    FROM tableName
    WHERE   (questionID = 14 AND
            answer = 'yes' ) OR
            (questionID = 54 AND
            answer <> 'empty') OR
            (questionid = 100 AND
            answer > 10)
    GROUP BY userID
    HAVING COUNT(*) = 3
    

    SQLFiddle Demo

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

Sidebar

Related Questions

This would be an example of database table: PHP script should limit query result
I think this will be better explained with an example I have the following
I would like a hint or much better a solution for this: I do
I would like to use this script https://github.com/jeromeetienne/jquery-qrcode (or is there even a better
This question is related to this , hopefully better phrased. I would like to
This would be it : y'(t)=y(t)/t-t^2/y^2*t y(1)=1 i have tried: function hazi3b() [T,Y] =
I would have thought that this would be an easy thing to do, but
Here's a problem I experience (simplified example): Let's say I have several tables: One
I have data that, in a normal query, would appear like this: Val1 Val2
I'm wondering about how you would implement an effect similar to this one implemented

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.