×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Is this resolved by joins?

Is this resolved by joins?

Is this resolved by joins?

(OP)
I have a table with form submissions. The first column (s) is the submission identifier. The second column (d) is the field identifier in the form. The third column (data) is the value that was submitted.

CODE

s|d|data
1|1|2020-07-01
1|2|A
2|1|2020-07-01
2|2|B
3|1|2020-07-02
3|2|B
4|1|2020-07-04
4|2|A
5|1|2020-07-05
5|2|A 

Is there a single query method where I can output the data from all records where the second field in the form = "A"?

CODE

s|data (field 2)|data (field 1)
1|A|2020-07-01
4|A|2020-07-04
5|A|2020-07-05 

RE: Is this resolved by joins?

(OP)
I think I resolved this as:

CODE

SELECT `s`, `data` FROM `table` 
WHERE `d` = 1 AND `s` IN (SELECT `s` FROM `table` WHERE `d` = 2 AND `data` = 'A') 

This produces an acceptable:

CODE

s|data
1|2020-07-01
4|2020-07-04
5|2020-07-05 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close