sql = "select * from book where bname like '%" & txtbname.Text & "%' and bauthor like '%" & txtauthor.Text & "%' and bpublish like '%" & txtpublish.Text & "%' and bdescription like '%" & txtdescription.Text & "%' order by bookid desc"组合查询,有是四个组合条件,这样写是不是效率比较低,我该怎么优化一下呢?
谢谢。
谢谢。
Dim WhereStr as string
if txtbname.Text<>"" then
WhereStr="bname like '%" & txtbname.Text & "%'"
ELSE IF ....
.....
ENDIF
这样是一个概率的问题,如果四个全输入的话,是一样的,但如果只输入一个的问,速度会比你的快些!
同意 flxa() 的方法.