I have some sort of evaluating application in the making, it’s almost finished but I’m stuck with rather complicated SQL query.
To start with here are linked tables I am using (MySQL):
table1: USERS (list of users)
userID | name | surname | email
table2: EVENT (list of events)
eventID | event_typeID | event_name | event_description
table3: EVENT_TYPE (list of event types, each has number of points that a person gets if it’s involved in it)
event_typeID | number_of_point
table4: USER_EVENT (list of user and event ID’s with multiplication factor)
user_eventID | userID | eventID | factor
Function to get needed data is, let’s say: function getUsersWithPoints($number_of_points_for_threshold)
What it needs to do is get name, surname, emailn total sum of points and all EVENTs user has been to for all users which have total number of points in events equal or greater than $number_of_points_for_threshold, but data must be taken indirectly, without getting it in another table.
Thanks in advance.
First I’m assuming that USER_EVENT has the event_typeID as a column. I can’t where event_typeID is referenced anywhere else. Try something like this:
Make sure you have indexes on user_event.userID and user_event.event_typeID a