Solved

Select Statement over 3 tables

Posted on 2014-12-17
7
138 Views
Last Modified: 2014-12-23
Hello There

I need help to solve this question: "Which members organise which event in a specific place?"
I've got 3 Tables:

member_table
| MNr | Name | Surname |

organises_table
| MNr | ENr |

Event_table
| ENr | Place |

*MNr = Member ID, ENr = Event ID

how can i manage that? I need in the end a list of all members, which organises a event at a specific place. Can someone help out?

best wishes
0
Comment
Question by:rdkli
  • 5
  • 2
7 Comments
 
LVL 2

Assisted Solution

by:Pratik Makwana
Pratik Makwana earned 500 total points
ID: 40504475
try this....

Select m.Mnr, m.Name, m.Surname, o.Enr, e.Place
from member_table m, organises_table o, Event_table e
Where m.Mnr=o.Mnr
And o.Enr=e.Enr

or


Select m.Mnr, m.Name, m.Surname, o.Enr, e.Place
from member_table m
Join organises_table o  ON m.Mnr=o.Mnr
Join Event_table e ON o.Enr=e.Enr
0
 

Author Comment

by:rdkli
ID: 40504788
heh, Thanks.. That's kinda embarrassing how simple it is.. Works Fine!

Can you help me out with these example too?

I need to answer this Question: "On which Date does the financier miss which Place?"
So I need the Place and Date on which the financier is missing. I've got this Data's:

function_table
| MNr | Function |
     3        financier

member_table
| MNr | Name | Surname |

participation_table
| Mnr | ENr |
      3        1
      3        2
Event_table
| ENr | Place | Date |
     1         A         2015-02-17
     2         B         2015-10-21
     3         C         2015-05-11


So I already know he's missing at the Event with the ID/Nr3. But i just dont get it to work with your example. Is these even possible?

Best Wishes
0
 
LVL 2

Assisted Solution

by:Pratik Makwana
Pratik Makwana earned 500 total points
ID: 40506360
Select m.Mnr, m.Name, m.Surname, p.Enr, f.Function, e.Place, e.Date
from function_table f, member_table m, participation_table p, Event_table e
Where f.Mnr=m.Mnr
And m.Mnr=p.Mnr
And p.Enr=e.Enr

you can add your where clause in this query as per your requirements like .e.date='2015-05-11' etc.....
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:rdkli
ID: 40506411
Thanks for the answer, but isn't it possible to make it more logical?

That the statement automaticly checks where the person's missing?

Because this way i have to check all events manually?
0
 

Assisted Solution

by:rdkli
rdkli earned 0 total points
ID: 40506610
Something like
select e.Place, e.Date From Event_table e
MINUS
Select e.Place, e.Date From Event_table e, participation_table p, function_table f
Where
p.ENr = e.ENr
f.MNr = p.Mnr
f.Function = 'financier'

But Minus doesnt work in Mysql.. any other options for Mysql?
0
 

Accepted Solution

by:
rdkli earned 0 total points
ID: 40506662
SELECT DISTINCT e.Date, e.Place FROM Event_table e
WHERE (e.Date, e.Place) NOT IN (Select e.Date, e.Place From participate p, Function f
Where p.VNr = e.VNR AND f.MNR = p.MNR AND f.Function = 'financier');

That works!! :-D thx for the help!! @Pratik, I learned alot =)
0
 

Author Closing Comment

by:rdkli
ID: 40514589
I Could do it by myself
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now