Posts: 2,536
Location: Western Maryland
|
I think I made an error in the SQL (post instead of poster).
Code:
SELECT d.*, u.name FROM diary d INNER JOIN users u ON d.poster=u.username WHERE d.datetime like '$month%' and d.datetime like '%$year' order by d.postno desc
Ok, just so I understand your schema, let me lay out my assumptions and you tell me if they are correct.
users.name is the user's real name.
diary.poster and users.username should be equal in determining which entries in the diary table belong to a particular user.
If these are true, then the JOIN is valid, but as I said, I made an error in the SQL that has now been corrected.
One suggestion, assign primary keys to each of your tables and use those to perform cross-table correlations. It is a much more efficient process to compare integers than it is to compare strings.
__________________
—Kyrnt
|