Select *from tableA
Select *from tableA where col="%%"
它们分别代表什么意思,查询结果一致吗?

解决方案 »

  1.   


    第二个会去掉col为NULL的行
      

  2.   

    select * from tableA 这个语句会查询出tableA中的所有的数据select * from tableA where col = '%%' 这个语句查询不出任何的数据
      

  3.   

    select * from tableA 是查询所有记录    能看懂
     
    select * from tableA
    where col=‘%%’ 这句不是判断语句吗    '%%'即使通配符那不是查询出col表中任意一个实体吗select * from tableA
    where col=‘%%’应该能查出所有记录吧 
      

  4.   


    select * from tableA where col = '%%'
    select * from tableA where col like '%%'--是两回事,一个查出符合%%这个字符串的数据,一个是所有数据
      

  5.   

    查找当col 为% 的 所有列@
      

  6.   

    --> 生成测试数据表: [tableA]
    IF OBJECT_ID('[tableA]') IS NOT NULL
    DROP TABLE [tableA]
    GO
    CREATE TABLE [tableA] ([col] [nvarchar](10),[%%] [nvarchar](10))
    INSERT INTO [tableA]
    SELECT 'abcd','abcd' UNION ALL
    SELECT '%%','aa'
    ----查询tableA所有记录
    Select *from tableA    
    /*
    col        %%
    ---------- ----------
    abcd       abcd
    %%         aa(2 行受影响)  
    */           
    --查询[col]与[%%]这两个字段值相等的记录
    Select *from tableA where col="%%"
    /*
    col        %%
    ---------- ----------
    abcd       abcd(1 行受影响)
    */--查询[col]值等于'%%'的记录
    Select *from tableA where col='%%'
    /*
    col        %%
    ---------- ----------
    %%         aa(1 行受影响)
    */
    --查询[col]字段除NULL值外所有值的记录
    Select *from tableA where col like '%%'
    /*
    col        %%
    ---------- ----------
    abcd       abcd
    %%         aa(2 行受影响)
    */
      

  7.   


    第一条SQL,查询A所有数据
    第二天Sql,符合%%的数据
      

  8.   

    第一条SQL,查询A所有数据
    第二天Sql,符合%%的数据