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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:03:36+00:00 2026-05-18T06:03:36+00:00

I have this table, and I want to select all distinct user_id values where

  • 0

I have this table, and I want to select all distinct user_id values where there is both an event=’AAAAAAAAAA’ and event =’XXXXXXXXXX’ (i.e. only result should be user_id=123456789)

unique_row_id  user_id          event       event_timestamp
----------------------------------------------------------------
0              123456789        AAAAAAAAAA  2010-01-20 15:00:00
1              123456789        abcdefghij  2010-01-20 15:00:05
2              123456789        XXXXXXXXXX  2010-01-20 15:00:15
3              987654321        AAAAAAAAAA  2010-01-20 16:00:00
4              987654321        abcdefghij  2010-01-20 16:00:05
5              987654321        abcdefghij  2010-01-20 16:00:15
6              111111111        XXXXXXXXXX  2010-01-20 16:01:00
7              111111111        XXXXXXXXXX  2010-01-20 16:01:05
8              111111111        XXXXXXXXXX  2010-01-20 16:01:15

I’ve tried both:

SELECT distinct user_id from mydata where event='AAAAAAAAAA' and event='XXXXXXXXXX'

which gives me an empty result set, and

SELECT distinct user_id from mydata where event='AAAAAAAAAA' or event='XXXXXXXXXX'

which gives me everything. Any suggestions – I’m guessing I need to go down the ‘join’ road here do I?

  • 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-05-18T06:03:36+00:00Added an answer on May 18, 2026 at 6:03 am

    Try this:

    select user_id from mydata where event='AAAAAAAAAAA'
    union
    select user_id from mydata where event='XXXXXXXXXXX';
    

    This will select both lists (users w/ AAA, users w/ XXX), and then merge them together, removing duplicate rows.

    Hope that helps!

    Thanks,
    Joe

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

Sidebar

Related Questions

i have this table: post{id, user_id, event_id} i want to fetch all posts thats
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
I have a HTML table as follows. I want retrieve row values from this
I want to select all distinct order_ids from my table, and order that list
I have this table: User id INT PK login VARCHAR UNIQUE I want to
I have this JSF table. I want to add row numbers. <?xml version=1.0 encoding=UTF-8?>
I have this JSF table which is used to display data. I want to
I have an SQL table like this : sales(product,timestamp) I want to display a
I'm overthinking this. I have colors stored in a database table, and I want
I have this mysql tables I want to display with jqgrid. The problem appears

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.