PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am trying to Join 3 tables together reports, reports2, reports3.. The reason why i want to do this is to display the totals for all 3 games for each member of our online group each month..
$query_scores = "SELECT total, bonus FROM reports WHERE user_name='$user_name' AND MONTH(date)=$today_month AND YEAR(date)=$today_year";
to display for 1 database and worked just fine..
i know the 3rd join didn't have a condition because last join script i did was only for 2 tables. im not sure on how to do 3 tables thats why im trying to get help on that one.. but also its be along time since i did joins. lol
select a.field as field1, b.field as field2 c.field as field3
from a
left join a on a.field = b.field
left join c on c.field = b.field
ambiguous means, if you had a field called "field" in all 3 tables, in your where clause you must specify the table name ( and everywhere else ), either that or use aliases
$query_scores = "SELECT r1.total, r1.bonus, r2.total2, r2.bonus2, r3.total3, r3.bonus3
FROM reports as r1
JOIN reports2 as r2 ON r1.user_name = r2.user_name
JOIN reports3 as r3 ON r3.user_name = r2.user_name
WHERE MONTH(r1.date)=$today_month AND YEAR(r1.date)=$today_year AND MONTH(r2.date)=$today_month AND YEAR(r2.date)=$today_year AND MONTH(r3.date)=$today_month AND YEAR(r3.date)=$today_year";
i don't get any errors but nothing shows up but where the total of everyones score it shows 22 which is a test score i made and that would be on reports table.. but doesn't show my user_name on the table either.
yeah i found out about the ambiguous last night when i added