该怎么写效率会比较高(关于sql语句)(50分)

  • 主题发起人 christin
  • 开始时间
C

christin

Unregistered / Unconfirmed
GUEST, unregistred user!
有一个表book 字段:bookname
现在有三个关键字 “A” “B” “C”
现在想查找出bookname里同时包含上面三个关键字的记录和包含有上面任一关键字的记录。
该怎么写效率会比较高???
 
select ...
union
select ...
 
呵呵,用LIKE能解决问题,至于效率嘛,确实是个难题
 
本人使用了这样的语句
select * from table
where a in (select bookname from table where b in(select bookname from table
where c in bookname)
但觉得好象效率不好,各位可否有比较好的方法
 
select * from table1 where (field1 like '%A%') or (field1 like '%B%') or (field1 like '%C%')

select * from table1 where (field1 like '%A%') and (field1 like '%B%') and (field1 like '%C%')
 
like觉得效率很低,如果记录多的话用时会太长的
 
QuickSilver的语句看起来和写起来都很舒服,但效率也不一定高,尤其是那个or的
 
接受答案了.
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
997
SUNSTONE的Delphi笔记
S
S
回复
0
查看
631
SUNSTONE的Delphi笔记
S
S
回复
0
查看
610
SUNSTONE的Delphi笔记
S
D
回复
0
查看
820
DelphiTeacher的专栏
D
顶部