1. 程式人生 > >Mysql 變量&分支

Mysql 變量&分支

In from 符號 ext2 lec 保存數據 true code HERE

SELECT
    CASE 3 
        WHEN 1 THEN    one 
        WHEN 2 THEN    two 
    ELSE more END;

SELECT
    CASE WHEN 1 > 0 THEN true ELSE false END AS one,
    CASE WHEN 0 > 0 THEN true ELSE false END AS two;

SELECT 
    CASE BINARY BB
        WHEN a THEN 1 
        WHEN bb
THEN 2 END; SELECT CASE B WHEN a THEN 1 WHEN b THEN 2 END; SELECT IF(1>2,2,3); select STRCMP(text2, text); 這裏要使用變量來保存數據,直接使用@變量 SET @cq:=(SELECT A.id FROM emis.view1 A WHERE id = 6); SELECT @cq AS 變量聲明賦值的方法; SET @c=(SELECT A.printer_addr FROM emis.view1 A WHERE id = @cq); SELECT @c AS
變量聲明賦值的方法 @cq 查找; 註意上面兩種賦值符號,使用set時可以用“=”或“:=”,但是使用select時必須用“:=賦值” SELECT @bb:=id FROM emis.view1 A WHERE id = @cq; SELECT @bb;

Mysql 變量&分支