数据库中有一列名为year。现在需要一个判断语句,判断year这一列中是否已经存在2010这个数据。用select来写么?具体怎么写?谢谢啦~~

解决方案 »

  1.   

    select 1 from 表 where year='2010'
    不知道楼主的year字段是什么类型的
      

  2.   


    就是去read这个数,看看有没有读到!
      

  3.   

    year是int型的,就是具体的年份。可是我要求的是一个判断语句啊,select后又能得出什么结论呢?是有啊还是没有啊?通过什么来判断呢?
      

  4.   

    你是在哪判断?
    在数据库: if exists(select 1 from 表 where year=2010)
    在程序判断就用 二楼的方法
      

  5.   

     (select count(*)  from 表 where year='2010') >0
    或if exists
      

  6.   

    if exists (select * from 表 where year like '%2010%')
    取返回值true或false判断
      

  7.   

    select count(*)  from 表 where year='2010'
    判断是否大于0