September 13th, 2013, 05:12 AM
Still having a problem with JOIN - returning wrong row for "ID"
Hi again everyone.
I am still having a massive issue with this join query, what I am trying is not working. If someone could point me in the right direction, I would greatly appreciate it.
I have 2 tables: facts & favorites.
I need ALL the data from facts (facts.ID, facts.body, facts.img ...etc)
On the favorites table, there are only 3 columns:
ID (which is also a column name in the facts table)
factID (which = ID in facts table)
What I am trying to accomplish is displaying all the facts that a user has favorited.
For example, if the user likes fact #7, in the table "favorites", it would be:
ID=1 (primary, auto inc)
userID = (ID of the USER)
factID = 7 (ID of the fact)
I know I have to use a join somehow, but every time I have tried, when I echo $row['ID'], I need that to be the facts.ID, not favorites.ID, which is what it is displaying. How would I write the query so that $row['ID'] shows the ID # from the FACTS table?
I hope I explained that well enough, feel free to ask Q's if not.
September 13th, 2013, 05:25 AM