簡體   English   中英

創建IF語句如果GROUP_CONCAT未返回任何結果

[英]Create An IF Statement If GROUP_CONCAT doesn't return any results

我有一個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";    

}

但即使沒有任何Twitter用戶,它總是會跳到其他地方。

任何幫助將不勝感激,以便我知道

如果沒有非NULL值, 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM