SELECT * from meets
LEFT JOIN teams as hteam on meets.meet_hometeam=hteam.team_id
LEFT JOIN teams as ateam on meets.meet_awayteam=ateam.team_id
LEFT JOIN teams as altloc on (meets.meet_altloc=altloc.team_id and meets.meet_altloc!='')
where meet_date between ($now+(4*86400)) and ($now+(5*86400) or meets.meet_id='2')
$var = $queryvar->fetch_object();
Thanks what I'm having issues with is when I call $var->ateam.team_town it is just treating the dot as a concatenation and not as an object to the table.
Don't
SELECT *
when doingJOIN
orUNION
queries. Instead, be specific about the columns you need, and if columns have the same name in different tables, you need to assign aliases to them.Aside from the necessity of differentiating columns with similar names, you get the benefit of being deterministic about the order in which they're returned and protection from future schema changes that add columns you don't want from being automatically pulled into this (like image blob data or something).
Then in your PHP, just call it by the alias you chose:
$var->hometeam_town, $var->hometown_id, $var->awayteam_town
etc...