問題是這樣的,我的數據庫(access)有一個標示狀態的整數字段state,值為0 1 2 ,要顯示的時候是顯示字符串.
要求是用select語句直接實現,數據庫是(access)謝謝.

解决方案 »

  1.   

    rs.open"select state from 表名",connmsgbox str(rs!state)'这样吗?
      

  2.   

    select  case when state=0 then "字串0" else case when state=1 then "字串1" else "字串2" end end from 表名
      

  3.   


       select decode(字段,1,....)..........
      

  4.   

    同意: cdwq88(不能没有你) ( 
    select  case when state=0 then "字串0" else case when state=1 then "字串1" else "字串2" end end from 表名
      

  5.   

    --确保State字段只有0,1,2三种状态,否则需要全部枚举!
    SELECT   FiledState= 
          CASE state
             WHEN '0' THEN '标识0'
             WHEN '1' THEN '标识1'
             ELSE '标识2'
          END,
       OtherFieldName
    FROM YourTableName
      

  6.   

    USE pubs
    GO
    SELECT    'Price Category' = 
          CASE 
             WHEN price IS NULL THEN 'Not yet priced'
             WHEN price < 10 THEN 'Very Reasonable Title'
             WHEN price >= 10 and price < 20 THEN 'Coffee Table Title'
             ELSE 'Expensive book!'
          END,
       CAST(title AS varchar(20)) AS 'Shortened Title'
    FROM titles
    ORDER BY price
    GO下面是结果集:Price Category        Shortened Title      
    --------------------- -------------------- 
    Not yet priced        Net Etiquette        
    Not yet priced        The Psychology of Co 
    Very Reasonable Title The Gourmet Microwav 
    Very Reasonable Title You Can Combat Compu 
    Very Reasonable Title Life Without Fear    
    Very Reasonable Title Emotional Security:  
    Coffee Table Title    Is Anger the Enemy?  
    Coffee Table Title    Cooking with Compute 
    Coffee Table Title    Fifty Years in Bucki 
    Coffee Table Title    Sushi, Anyone?       
    Coffee Table Title    Prolonged Data Depri 
    Coffee Table Title    Silicon Valley Gastr 
    Coffee Table Title    Straight Talk About  
    Coffee Table Title    The Busy Executive's 
    Expensive book!       Secrets of Silicon V 
    Expensive book!       Onions, Leeks, and G 
    Expensive book!       Computer Phobic And  
    Expensive book!       But Is It User Frien (18 row(s) affected)
      

  7.   

    在access數據庫 應該這樣!
    SELECT CgOrderId, iif (CgState =0 , '開始採購',(iif (CgState =1 , '採購結束','放棄採購'))) AS 採購單狀態
    FROM TBCgOrder;
    结果集:
    CgOrderId         採購單狀態
    OD04112601 開始採購
    OD04112602 開始採購
    OD04112603 採購結束
    OD04113001 放棄採購