scarhand Posted April 1, 2009 Share Posted April 1, 2009 You'll be able to see what I'm trying to do: $sql = $db->query("select s.*, u.displaygroupid as did, if(did = 0, u.usergroupid as gid, u.displaygroupid as gid) (select opentag from " . TABLE_PREFIX . "usergroup where usergroupid = gid) as opentag, (select closetag from " . TABLE_PREFIX . "usergroup where usergroupid = gid) as closetag from " . TABLE_PREFIX . "shoutbox as s, " . TABLE_PREFIX . "user as u order by id desc limit " . $vbulletin->options['ddsb_show'] . ""); Doesn't work. Can someone show me the proper way of writing this query? Quote Link to comment https://forums.phpfreaks.com/topic/152121-if-select-this-else-select-that/ Share on other sites More sharing options...
Maq Posted April 1, 2009 Share Posted April 1, 2009 You'll be able to see what I'm trying to do: Not really... How doesn't it work? Does it throw any errors? Quote Link to comment https://forums.phpfreaks.com/topic/152121-if-select-this-else-select-that/#findComment-798920 Share on other sites More sharing options...
fenway Posted April 2, 2009 Share Posted April 2, 2009 Alias the expression instead: if(did = 0, u.usergroupid as gid, u.displaygroupid as gid) becomes if(did = 0, u.usergroupid, u.displaygroupid) as gid Quote Link to comment https://forums.phpfreaks.com/topic/152121-if-select-this-else-select-that/#findComment-799332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.