Mysql subquery with where clause
I need help. I have three tables, and there are names: hall, hall_quantified_details and hall_hall_quantified_details, and they look like this:
Hall
hall_id | hall_name
1 Hall 1
2 Hall 2
hall_quantified_details
hall_quantified_details_id | name_quantified
1 space
2 seats
hall_hall_quantified_details
hall_hall_quantified_details_id | hall_id | hall_quantified_details_id | value
1 1 1 100m2
2 1 2 500seats
And I want to return with the value request name and value for hall_id 1, I have a request, but it only returns me the name hall_quantified_details_id ... The request looks like this:
SELECT p.name_quantified
FROM hall_quantified_details p
WHERE p.hall_quantified_details_id IN (
SELECT pns.hall_quantified_details_id
FROM hall_hall_quantified_details pns
WHERE pns.hall_id = 1
);
So, I want to go back to hall_id 1 from the result of hall_hall_quantified_details, which looks like this: space 100; places for 500 places.
+3
source to share