MySQL Forums
Forum List  »  Newbie

Check a table with a number in one row of another table
Posted by: Hans Huber
Date: July 28, 2020 05:58AM

Hi,

can someone help me with the query I need. I looked already for hours but I do not get it.

So here is the thing....

I have 3 tables

Table 1 event
-----------------------------------------
| ID | name | date | seats | ... |
-----------------------------------------
| 1 | name1 | 01/01 | 50 | ... |
| 2 | name2 | 02/02 | 60 | ... |
| 3 | name3 | 03/03 | 55 | ... |
| 4 | name4 | 04/04 | 40 | ... |
| 5 | name5 | 05/05 | 100 | ... |
| 6 | name6 | 06/06 | 20 | ... |
-----------------------------------------

Table 2 person
-----------------
| ID | person|
-----------------
| 1 | name1 |
| 2 | name2 |
| 3 | name3 |
| 4 | name4 |
| 5 | name5 |
| 6 | name6 |
-----------------

Table 3 reservation

---------------------------------
| ID | idperson |idevent|
---------------------------------
| 1 | 1 | 2 |
| 2 | 1 | 5 |
| 3 | 2 | 5 |
| 4 | 4 | 2 |
| 5 | 2 | 1 |
| 6 | 6 | 3 |
---------------------------------

So here my Question:

When I offer a Person the events I want to make sure, that there are still empty seats.So I need to count the idevent from reservation and check if the number of seats in event is allready reached. At the end I want to have a List with all the available events which the person has not booked yet.

If anyone has a Tipp for me I would be very happy and thankful.

Options: ReplyQuote


Subject
Written By
Posted
Check a table with a number in one row of another table
July 28, 2020 05:58AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.