Ok... I'm stuck on this one... let me try to lay out the senario:
I got two tables:
t1 got
user_id int(11) primary key and auto_increment
name varchar(63)
t2 got
user_id int(11)
field_id int(11) index
day_id int(11) index
how_many int(11)
I also got two variables... $field and $day.
one user can be in t2 unlimited times. In one row field_id OR day is is filled in, not both...
I wanna select the how_many (and matching user_id and name) field from t2 (t1), where either $field match with field_id or $day matches day_id...
That's ok... this i can do.. it's just an ordenary select with a join... BUT... I only want there to be one row in the result for each user_id and not more than one... in this one row all the how_many fields are summed... is this posible?
I got two tables:
t1 got
user_id int(11) primary key and auto_increment
name varchar(63)
t2 got
user_id int(11)
field_id int(11) index
day_id int(11) index
how_many int(11)
I also got two variables... $field and $day.
one user can be in t2 unlimited times. In one row field_id OR day is is filled in, not both...
I wanna select the how_many (and matching user_id and name) field from t2 (t1), where either $field match with field_id or $day matches day_id...
That's ok... this i can do.. it's just an ordenary select with a join... BUT... I only want there to be one row in the result for each user_id and not more than one... in this one row all the how_many fields are summed... is this posible?