OK, so, there are two ways in which I can achieve the same result, a Subselect in my query as follows:
SELECT nu.id, nu.username, nu.user_level, nu.phpbb_id, nu.real_name, nu.telephone, nu.email, nu.monster_points, nu.ref_points,
(SELECT lv.name FROM hh_user_levels lv WHERE lv.user_level = nu.user_level) AS 'level_name' FROM hh_user_new nu
OR by using a PHP switch on a statement without the subselect as follows:
switch($result['user_level']) {
case 0:
$level_name = 'Not Logged In';
break;
case 1:
$level_name = 'basic user';
break;
case 2:
$level_name = 'member';
break;
}
(there are actually 10 possibilities, but I didn't think you'd be interested in all of them!)
So, my question is, which is more efficient? Achieving this through a MySQL subselect or via the PHP switch on each result?
Cheers!
Seb