This topic is locked
[SOLVED]

 Displaying Child Table Fields

4/1/2013 2:25:42 PM
PHPRunner General questions
S
supermessiah author

I am building.

A
Abhijeet 4/3/2013



I am building this soccer database at the moment containing thousands of English league matches featuring the two teams, the result etc. It has a relational structure, and I'm almost there in terms of what I want to achieve. But the big problem is that (as you can see in the image below), because I have used a separate table for storing the number of goals a team scores in a match, there is an issue getting this data displayed how I want to.
I want the two teams involved in the match to be displayed side by side, as well as the number of goals they've scored side by side as well. At the moment, there are two entries for every match - one for the home side and one for the away team, which means a lot of repeating data. I only want one entry for one match
As you can see in the first image, the user can click on one of the rows which reveals another table featuring the goals scored and the two team names. Okay, this works, but it's by no means a very effective way of presenting the data.
As you can see in the database structure, there is only one field for team and one field for goals, so I can't find a way of getting the data of two records crammed into one essentially.
So to put simply, how do I get that data from the child table (the goals and two teams) displayed alongside all the normal columns?

The database structure:



This is not a sql forum but still here is your answer, it lies in the sql you are giving. Try giving command something like this which will bring them in one line.
select tbmatchdetails.matchid as matchid,

tbmatchdetails.teamid as teamfirst,

sum((tbmatchdetails.goals)) as firstendgoals,

tbmatchdetails.teamid as teamsecond,

sum((tbmatchdetails.goals)) as secondendgoals

from tbmatchdetails group by

teamfirst,teamsecond,matchid

S
supermessiah author 4/3/2013

Thanks, but I did manage to get it working using this code:

Sergey Kornilov admin 4/3/2013

SQL won't allow you to update more than one table at once. To avoid updating field from joined tables you need to use BeforeAdd/BeforeEdit events and unset() all joined fields. See sample code at http://xlinesoft.com/phprunner/docs/update_multiple_tables.htm

S
supermessiah author 4/3/2013



SQL won't allow you to update more than one table at once. To avoid updating field from joined tables you need to use BeforeAdd/BeforeEdit events and unset() all joined fields. See sample code at http://xlinesoft.com/phprunner/docs/update_multiple_tables.htm

Sergey Kornilov admin 4/4/2013

This code doesn't really make any sense to me. For example, the first part of code will produce SQL query like this one:

Update tblDivision set DivisionID=5 where DivisionID=5


In other words - this code not doing anything.

S
supermessiah author 4/4/2013

[quote name='admin' date='04 April 2013 - 02:45 PM' timestamp='1365083126' post='70376']

This code doesn't really make any sense to me. For example, the first part of code will produce SQL query like this one:

[code]