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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:01:53+00:00 2026-06-01T00:01:53+00:00

I have a table that looks like so: +—–+————–+———+———-+———————+———————+ | id | username |

  • 0

I have a table that looks like so:

+-----+--------------+---------+----------+---------------------+---------------------+
| id  | username     | case_id | status   | date_assigned       | date_removed        |
+-----+--------------+---------+----------+---------------------+---------------------+
|  21 | hemcreynolds | 802     | inactive | 2007-08-20 07:15:48 | 2008-04-15 16:08:54 |
| 133 | licox        | 868     | active   | 2007-09-02 11:55:37 | 0000-00-00 00:00:00 |
|   3 | kashepherd   | 794     | inactive | 2007-08-17 13:54:39 | 2010-08-12 14:40:37 |
|   4 | tithomas     | 795     | active   | 2007-08-17 13:56:06 | 0000-00-00 00:00:00 |
|   5 | stcosse      | 795     | inactive | 2007-08-17 13:56:26 | 2007-09-25 10:02:03 |
|   6 | mefong yit   | 914     | active   | 2007-08-17 14:00:29 | 0000-00-00 00:00:00 |
|   7 | tamouledoux  | 842     | active   | 2007-08-17 14:09:16 | 0000-00-00 00:00:00 |
|   9 | chgross      | 903     | active   | 2007-08-18 08:38:38 | 0000-00-00 00:00:00 |
|  20 | ticrane      | 802     | inactive | 2007-08-20 07:15:41 | 2008-04-15 16:44:35 |
|  19 | hemcreynolds | 818     | inactive | 2007-08-20 07:15:12 | 2008-04-15 16:08:57 |
+-----+--------------+---------+----------+---------------------+---------------------+

I’d like to run a query to find which cases a user has been assigned to by username, e.g.

SELECT username,case_id from assignments WHERE username = 'ticrane'

I would then like to find all the other users assigned to the cases that my user (ticrane) is assigned to:

 SELECT * FROM assignements WHERE case_id = (all of the case ids generated by the previous query)

I’d like to do this in a single query. I imagine that some kind of join is in order here, but I don’t think you can join results from the same table. Confused. Any suggestions?

  • 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-01T00:01:54+00:00Added an answer on June 1, 2026 at 12:01 am

    It is perfectly legal to join a table to itself, but you need to give an alias to at least one of the two “copies” of the table so that the statement is not ambiguous.

    SELECT
        assignments_join.*
    FROM
        assignments AS assignments_base
        JOIN assignments AS assignments_join ON
            assignments_base.case_id = assignments_join.case_id
    WHERE
        assignments_base.username = 'ticrane'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that looks like: Client_ID | Order_ID | 10 | 1
I have a table that looks like this: nid vid tid 1 2 3
I have a table that looks like this: <table> <thead> <!-- random table headings
I have a table that looks like the following: <table class=theClass> <tr> <td class=anotherClass><strong>Label1:</strong></td>
I have a table that looks like this: |StreetName NR| NR | |Teststreet 34|
I have a table that looks like this: id count 1 100 2 50
I have a table that looks like this for about ~30 students: StudentID Course*
I have a table that looks like this: ╔════╦═════════╦═════════╦═══════╗ ║ id ║ deleted ║
I have a table that looks like so: CREATE TABLE `countrytable` ( `countryCode` varchar(2)
I have a table that looks like this: id| country | =================== 1 |

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.