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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:53:31+00:00 2026-05-19T10:53:31+00:00

I have a database table that records movements of users in a game. Each

  • 0

I have a database table that records movements of users in a game. Each time they move I record their user id, the move_index (increments each row) and the id of the zone they are in. I have a special move_index value of -1 to indicate the last movement of that user.

id   user_id  move_index  zone_id   
----------------------------------------------------------------
0    11        0          0  
1    11        1          0 
2    11        2          0   
3    11       -1          3    

4    22        0          0   
5    22        1          1   
6    22        2          1    
7    22       -1          3    

I want to do two things with sql:

  • Detect all the users who started and finished in specific zones (e.g. started in zone 0 and finished in zone 3)
  • Extending the above, detect all users who started and finished in specific zones AND passed through a specific zone.

I know how to do this with multiple SQL statements & java – but I don’t know how to do this in a single SQL statement. Do I need to do a select and then a select on the results of this select ?

  • 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-19T10:53:32+00:00Added an answer on May 19, 2026 at 10:53 am

    You can simply carry out a SUBQUERY to achieve this within a “single” query.

    e.g.: SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);

    In essence, you’re using the results of the “inner” SELECT as the working data set for the “outer” SELECT.

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

Sidebar

Related Questions

I have table that shows some records from database. each table has a column
I have a table within my database that has many records, some records share
I have a database table where all the records are linked among each other
I have this homework question: Assume a Database table has 0 records at time
I have this database table that contains emails like 300 records, emails{email,name,join_date); and I
I have a database with a table that records data coming from various sources.
Say you have a ServiceCall database table that records down all the service calls
I have a gridview that shows records from a database table. Now, I want
Let's say I have a function that inserts records into a database table with
I have a database table that holds parent and child records much like 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.