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.   

    --> 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 個資料列受到影響)
    */
      

  2.   


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

  3.   

    ----------------------------------------------------------------
    -- 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 行受影响)
    */
      

  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==========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 行受影响)
      

  6.   

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

  7.   

    问题描述是不是不正确
    “并且”对应的是 and
      

  8.   

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

  9.   

    ----------------------------------------------------------------
    -- 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 行受影响)
    */
      

  10.   

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

  11.   

    --测试数据
    if object_id [[tb] is not null drop table [tb]
    GO
    create table [tb](id int,name nvarchar(20),pass nvarchar(4),message nvarchar(40),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 sigan=1
    union all
    select * from [tb] where id=5 
    order by id
      

  12.   

    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--1
    select * from tb where id = 5 or sigan = 1 order by id --2
    select * from tb where id = 5
    union all
    select * from tb where sigan = 1 
     order by id drop table tb/*
    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 行)*/
      

  13.   

    描述有问题呀   不过要图里面的数据就是 select * from tablname where id = 5 or sigan  = 1
      

  14.   

    我现在想要得到ID 为5 并且 sign为1的 数据信息 
    ------------------------------------------
    看你结果数据你的描述应该为:
    ID 为5 或者 sign为1id=5 or sign=1
      

  15.   

    SELECT * FROM TB 
    WHERE id = 5 AND sigan  = 1
    /
      

  16.   

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

  17.   

    并且我晕select * from tb where id=5 and sigan=1
      

  18.   

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

  19.   

    按你题目的意思,就应该是这样了select * from tablname where id = 5 and sigan  = 1
      

  20.   


    IF(OBJECT_ID('TEMPDB..#T') IS NOT NULL)
    BEGIN
    DROP TABLE #T
    END
    CREATE TABLE #T
    (
    [ID] INT,
    [NAME] NVARCHAR(100),
    [PASS] NVARCHAR(100),
    [MESSAGE] NVARCHAR(1000),
    [SIGAN] INT
    )
    INSERT INTO #T SELECT 3,'FF','FFF','GGG',0
    INSERT INTO #T SELECT 4,'TT','TT','TTT',1
    INSERT INTO #T SELECT 5,'GG','GG','GG',0
    INSERT INTO #T SELECT 6,'EE','EE','EE',1
    INSERT INTO #T SELECT 7,'HH','HH','HH',1
    INSERT INTO #T SELECT 8,'KK','KKK','KK',0SELECT * FROM #T WHERE [ID]=5 OR [SIGAN]=1
    -------------------------------------------
    4 TT TT TTT 1
    5 GG GG GG 0
    6 EE EE EE 1
    7 HH HH HH 1
      

  21.   

    SELECT * FROM tablname WHERE id = 5 and sigan  = 1
      

  22.   


    select * from tablname where id = 5 and sigan  = 1貌似是 and 吧
      

  23.   

    select * from 表名  where (id = 5 or sigan = 1)
    最好加上括号  如果你还有其他查询条件的话
      

  24.   

    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--1
    select * from tb where id = 5 or sigan = 1 order by id --2
    select * from tb where id = 5
    union all
    select * from tb where sigan = 1 
     order by id drop table tb/*
    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 行)*/