0

Currently doing a project in android studio in java and I'm trying to query two tables in sql. The tables are as follows:

Bookings table

Bookings table

User_Bookings table

User_Bookings table

User table just for reference

enter image description here

Is there a way do to a UNION or INNER JOIN and connect these two tables with just the userID ?

Say for example for the user with ID 2 I want from the Bookings table the departure time & departure date (12:30 & 12/5/20222) and from the User_Bookings table I want the number of people (2).

Or is UNION/INNER JOIN not the right operators for what I am trying to achieve ? As I have been trying and brushing up on my SQL skills but I can't seem to get ahead of it.

Any help appreciated.

1
  • 1
    select * from User a join User_bookings b on a.Id = b.UserId join Bookings c on b.bookingId = c.Id Commented May 2, 2022 at 15:54

1 Answer 1

1
SELECT * FROM Bookings b INNER JOIN User_Bookings ub ON b.bookingID=ub.bookingID where ub.userID = <pass_parameter_actual_userID>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.