满足多个条件的查询应该怎么做?!
本人要用多个combobox来选择以后(有的可选,有的可不选),在DBGrid中显示出符合条件的选项。问题是:不知道如果让它判断出如果combobox(其中一个)为空值时,就跳过该空的combobox。本人用的是SQL语句。
datamodule4.adoquery1.Close;
datamodule4.ADOQuery1.SQL.Clear;
begin
if (combobox6.ItemIndex<>-1) then
a:=combobox6.Items[combobox6.itemindex];
if (combobox8.ItemIndex<>-1) then
c:=combobox8.Items[combobox8.itemIndex];
if (combobox9.ItemIndex<>-1) then
d:=combobox9.Items[combobox8.itemIndex];
if (combobox10.ItemIndex<>-1) then
e:=combobox10.Items[combobox8.itemIndex];
if (combobox11.ItemIndex<>-1) then
f:=combobox11.Items[combobox8.itemIndex];
if (combobox12.ItemIndex<>-1) then
g:=combobox12.Items[combobox8.itemIndex];
datamodule4.ADOQuery1.SQL.Add('select * from 学生信息 where 性别 like'''+a+''' or 民族 like'''+c+'''or 学生类型 like'''+d+''' or 院系 like'''+e+''' or 政治面貌 like'''+f+''' or 专业 like'''+g+'''');