How would I go about selecting from one mysql table (friends) and ordering the results by fields in another table (users)?
The tables are setup as follows:
CREATE TABLE `users` (
`id` int(12) NOT NULL auto_increment,
`first_name` varchar(100) NOT NULL default '',
`last_name` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
CREATE TABLE `friends` (
`id` int(12) NOT NULL auto_increment,
`user_id` int(2),
`mutual` int(2) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
basically what I need to do is pull in the user_ids from the friends table, match them to the users table and get the users data, then order the output by the following:
concat(users.first_name, users.last_name) ASC, friends.mutual DESC