newbreed65 Posted December 1, 2008 Share Posted December 1, 2008 Hi Right I’m currently trying to join my users table with my people table in order to show the name of the last user to update it instead of there numerical value. I just previously did it with my movies table with no issues and the names of the fields and tables are all correct it’s just when I add the join to the mysql query that it decide that my people table is empty although it was showing all the records before I tried adding the join….. Any idea what may be wrong...If you even get my hyperactive babble lol Here is the code I used with movies which works fine $sql = "SELECT movie.*, users.fullname " . "FROM users JOIN movie " . "ON (movie.editby=users.user_id) " . "ORDER BY ". $order[$ord]; $result = mysql_query($sql) or die(mysql_error()); And here is the code I’ve got for people /*this one works fine its just when i add the join $sql = "SELECT * " . "FROM people ORDER BY ". $order[$ord]; */ $sql = "SELECT people.*, users.fullname " . "FROM users JOIN people " . "ON (people.lastmodified=users.user_id) " . "ORDER BY ". $order[$ord]; $result = mysql_query($sql) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/135007-why-does-my-people-table-decide-its-emptygrrr-shakes-fist/ Share on other sites More sharing options...
gevans Posted December 1, 2008 Share Posted December 1, 2008 This may be a stupid question, but people.lastmodified is a user id and not a timestamp or something right? Link to comment https://forums.phpfreaks.com/topic/135007-why-does-my-people-table-decide-its-emptygrrr-shakes-fist/#findComment-703126 Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 Are there actually records on both tables that are satisfying join criteria (i.e. people.lastmodified=users.user_id ) Also, you can write your queries like this $sql = "SELECT people.*, users.fullname FROM users JOIN people ON (people.lastmodified=users.user_id) ORDER BY {$order[$ord]}"; less quotes Link to comment https://forums.phpfreaks.com/topic/135007-why-does-my-people-table-decide-its-emptygrrr-shakes-fist/#findComment-703129 Share on other sites More sharing options...
newbreed65 Posted December 1, 2008 Author Share Posted December 1, 2008 This may be a stupid question, but people.lastmodified is a user id and not a timestamp or something right? nope not stupid...thank you! anyway you just made me realise what I did wrong :-\ Link to comment https://forums.phpfreaks.com/topic/135007-why-does-my-people-table-decide-its-emptygrrr-shakes-fist/#findComment-703139 Share on other sites More sharing options...
newbreed65 Posted December 1, 2008 Author Share Posted December 1, 2008 Are there actually records on both tables that are satisfying join criteria (i.e. people.lastmodified=users.user_id ) Also, you can write your queries like this $sql = "SELECT people.*, users.fullname FROM users JOIN people ON (people.lastmodified=users.user_id) ORDER BY {$order[$ord]}"; less quotes yeah I just didnt realise till my first reply that I had used the wrong field for the people table part of the join thanx about the quotes thing, Ive just been doing that since the book I read did it and phpMyadmin....do you know why they would do it that way? Link to comment https://forums.phpfreaks.com/topic/135007-why-does-my-people-table-decide-its-emptygrrr-shakes-fist/#findComment-703151 Share on other sites More sharing options...
gevans Posted December 1, 2008 Share Posted December 1, 2008 makes it easier for you to understand and read while you learn Link to comment https://forums.phpfreaks.com/topic/135007-why-does-my-people-table-decide-its-emptygrrr-shakes-fist/#findComment-703164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.