id  name pass  message sigan
  3    ff   fff   ggg     0
  4    tt   tt    ttt      1
  5     gg  gg     gg      0
  6    ee    ee    ee      1
  7     hh   hh    hh       1
  8     kk   kkk   kk       0以上是我举的数据信息 我现在想要得到ID 为5 并且 sign为1的 数据信息
 id  name pass  message sigan
 
  4    tt   tt    ttt      1
  5     gg  gg     gg      0
  6    ee    ee    ee      1
  7     hh   hh    hh       1
 不知道有办法吗  请帮助

解决方案 »

  1.   

    ----------------------------------------------------------------
    -- Author  :fredrickhu(我是小F,向高手学习)
    -- Date    :2009-11-05 10:27:12
    -- Version:
    --      Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86) 
    -- Nov 24 2008 13:01:59 
    -- Copyright (c) 1988-2005 Microsoft Corporation
    -- Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 1)
    --
    ----------------------------------------------------------------
    --> 测试数据:[tb]
    if object_id('[tb]') is not null drop table [tb]
    go 
    create table [tb]([id] int,[name] varchar(2),[pass] varchar(3),[message] varchar(3),[sigan] int)
    insert [tb]
    select 3,'ff','fff','ggg',0 union all
    select 4,'tt','tt','ttt',1 union all
    select 5,'gg','gg','gg',0 union all
    select 6,'ee','ee','ee',1 union all
    select 7,'hh','hh','hh',1 union all
    select 8,'kk','kkk','kk',0
    --------------开始查询--------------------------select * from [tb] where id=5 or sigan=1
    ----------------结果----------------------------
    /* id          name pass message sigan
    ----------- ---- ---- ------- -----------
    4           tt   tt   ttt     1
    5           gg   gg   gg      0
    6           ee   ee   ee      1
    7           hh   hh   hh      1(4 行受影响)
    */
      

  2.   

    --> Title  : Generating test data [tb]
    --> Author : wufeng4552
    --> Date   : 2009-11-05 10:25:14
    if object_id('[tb]') is not null drop table [tb]
    go
    create table [tb] (id int,name nvarchar(4),pass nvarchar(6),message nvarchar(6),sigan int)
    insert into [tb]
    select 3,'ff','fff','ggg',0 union all
    select 4,'tt','tt','ttt',1 union all
    select 5,'gg','gg','gg',0 union all
    select 6,'ee','ee','ee',1 union all
    select 7,'hh','hh','hh',1 union all
    select 8,'kk','kkk','kk',0
    select * from [tb] where sigan=1
    union all
    select * from [tb] where id=5 
    order by id
    /*
    id          name pass   message sigan
    ----------- ---- ------ ------- -----------
    4           tt   tt     ttt     1
    5           gg   gg     gg      0
    6           ee   ee     ee      1
    7           hh   hh     hh      1(4 個資料列受到影響)
    */
      

  3.   

    我现在想要得到ID 为5 并且 sign为1的 数据信息 
    id  name pass  message sigan   4    tt  tt    ttt      1 
      5    gg  gg    gg      0 
      6    ee    ee    ee      1 
      7    hh  hh    hh      1 
    从结果集看,应该是 id=5 or  sign=1
    select * from tb where id=5 or sign=1
      

  4.   

    select * from tablname where id = 5 or sigan  = 1
      

  5.   

    if object_id('[tb]') is not null drop table [tb]
    go
    create table [tb] (id int,name nvarchar(4),pass nvarchar(6),message nvarchar(6),sigan int)
    insert into [tb]
    select 3,'ff','fff','ggg',0 union all
    select 4,'tt','tt','ttt',1 union all
    select 5,'gg','gg','gg',0 union all
    select 6,'ee','ee','ee',1 union all
    select 7,'hh','hh','hh',1 union all
    select 8,'kk','kkk','kk',0
    select * from [tb] where id = 5 or sigan = 1
      

  6.   


    /*
    id          name pass   message sigan
    ----------- ---- ------ ------- -----------
    4           tt   tt     ttt     1
    5           gg   gg     gg      0
    6           ee   ee     ee      1
    7           hh   hh     hh      1(4 個資料列受到影響)
    */
      

  7.   

    select * from tablname where id = 5 and sigan  = 1