日期:2014-05-18  浏览次数:20481 次

在我的数据库中有五个int型数据类型的数据,数据分别为1,2,null,请问怎么查询
在我的数据库中有五个int型数据类型的数据,数据分别为1,2,null,请问怎么查询
xinhao=trim(Request.from( "model "))
corp_code=Trim(Request.from( "corp_code "))
cheshi=trim(request.Form( "testing "))
qie=trim(request.Form( "anxious "))
mopian=trim(request.Form( "mopian "))
bangding=trim(request.Form( "bangding "))
cent_check=Trim(Request.form( "cent_check "))
auto_check=Trim(Request.Form( "auto_check "))
上面的代码为取出单选框的值,值有可能为空,或1,或2,这里面的空对应数据库里main_product里相对应数据的NULL,请问下面的代码怎么写?

Set   padd1   =   Server.CreateObject( "ADODB.RecordSet ")
Sq   =   "Select   *   From   [main_product]   Where   xinhao= ' "&xinhao& " '   and   selkelev= ' "&corp_code& " '   and   cheshi= ' "&cheshi& " '   and   qie= ' "&qie& " '   and   mopian= ' "&mopian& " '   and   bangding= ' "&bangding& " '   and   cent_check= ' "&cent_check& " '   and   auto_check= ' "&auto_check& " ' "
padd1.Open   Sq,Conn,1,3



------解决方案--------------------
col1 = 1 or col1 is null
------解决方案--------------------
--参照这句写
Select * From [main_product] Where isnull(xinhao,-1) = isnull(xinhao,-1)
------解决方案--------------------
应该是一样的,都是不确定的值
------解决方案--------------------
Sql = "Select *
From [main_product]
Where (xinhao IS NULL OR xinhao= ' "&xinhao& " ')
and (selkelev IS NULL OR selkelev= ' "&corp_code& " ')
and (cheshi IS NULL OR cheshi= ' "&cheshi& " ')
and (qie IS NULL OR qie= ' "&qie& " ')
and (mopian IS NULL OR mopian= ' "&mopian& " ')
and (bangding IS NULL OR bangding= ' "&bangding& " ')
and (cent_check IS NULL OR cent_check= ' "&cent_check& " ')
and (auto_check IS NULL OR auto_check= ' "&auto_check& " ') "