我有一个GROUP_CONCAT:
GROUP_CONCAT(CASE WHEN c.twitter IS NOT NULL AND
c.twitter <> '' THEN CONCAT('!',c.twitter) END SEPARATOR ' ') AS tweetWinners
当用户在数据库中有推特名称时,这很有用。然后我就这样存储:
$tweeters = $row['tweetWinners'];
这给了我一个列表:
@twitteruser1 @twitteruser2 @twitteruser3
但是,我想显示两个不同的选项:
if ($tweeters == '') {
echo "Something";
} else {
echo "$tweeters";
}
但即使没有任何推特用户,也总会跳到其他地方。
任何帮助都将受到赞赏,以便我知道
答案 0 :(得分:2)
GROUP_CONCAT()
将返回NULL
。
见http://dev.mysql.com/doc/refman/5.5/en/group-by-functions.html#function_group-concat
NULL
不是空字符串。 COALESCE
可能有所帮助。
http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html#function_coalesce