偶不是高手,解解看吧。 首先假设查询界面中,姓名、学号、成绩是由edit输入,性别由comboBox输入,出生日期由DateTimePicker输入(它的处理有点特殊,因为有非空初始值)。 procedure Tform1.btnQueryClick(Sender: TObject); var cond: string; begin cond := '; if edtName.Text <> ' then if cond = ' then cond := Format('name like %s',[QuotedStr(AnsiQuotedStr(edtNamt.Text,'%'))]) //姓名支持模糊查询 else cond := Format('%s AND name like %s',[cond,AnsiQuotedStr(edtNamt.Text)]); if edtNumber.Text <> ' then if cond = ' then cond := Format('Number = %s',[edtNumber]) esle cond := Format('%s AND Number = %s',[cond,edtNumber]); if cbSex.Text <> ' then if cond = ' then cond := Format('Sex = %s',[cbSec.Text]) else cond := Format('%s AND Sex = %s',[cond,cbSec.Text]); if cond <> ' then with query1 do begin close; sql.clear; sql.Add('select * from 学生表'); sql.Add('where '+ cond); open; end; end;
----------------------------------------------
这是什么高难度查询哦? 是很简单的查询哈。
----------------------------------------------
Function IThink(Boy,Girl : TPerson) : String; begin if Boy.钱 < 10W then Girl.Say(''滚!'') else begin if Girl.Anser = ''我愿意'' then Result := ''结婚'' else Result := IntToStr(88); end; 风过不折→百炼成尧 QQ: 7315910