MySQL クエリを記憶する場合の文字列連結

必要:

SELECT name, store_type from pigcms_salesev_store 

原内容

表内のさまざまなstore_typeに従って、名前の後に識別子を追加します

0:「店舗」
1:「倉庫」

SQL文

SELECT 
Concat(name,'【',CASE store_type WHEN 0 THEN '门店' WHEN 1 THEN '仓库' END,'】') as store_name 
from store 

レンダリング

レンダリング

Concat() は文字列を連結します。つまり、複数の文字列を接続して長い文字列を形成します。

Concat() には、カンマで区切られた 1 つ以上の指定文字列が必要です。

おすすめ

転載: blog.csdn.net/Depressiom/article/details/123108964