sql查询问题(50分)

  • 主题发起人 主题发起人 pandame
  • 开始时间 开始时间
P

pandame

Unregistered / Unconfirmed
GUEST, unregistred user!
我在combobox3输入南京路65号,我想查询出road.name为“南京路”的路段的记录

s1:='select * from roads,do
orplate where (doorplate.ID = roads.ID) and ( name like '''+'%'+(combobox3.text)+'%'+''') ORDER BY roads.MAPINFO_ID';
这语句从语法上看没错吧?可是我怎么就是查询不出东西来呢?
 
有错误提示吗?字段列(Name)明确吗? 去查询分析器里执行一下吧
 
你这样子是查name字段包含combobox3.text的记录,当然查不出来了
 
s1:='select * from roads,do
orplate where (doorplate.ID = roads.ID) and ('''+'%'+(combobox3.text)+''' like name +'%')
 
name改成[name]
 
谢谢大家给我支招,我来试试~
 
s1:='select * from roads,do
orplate where (doorplate.ID = roads.ID) and ('''+'%'+(combobox3.text)+''' like name +'%')';
我改成这样后,它报这样的错:
[Error] searchUnit.pas(109): Illegal character in input file: '%' ($25)
怎么会这样呢?
 
s1:='select * from roads,do
orplate where (doorplate.ID = roads.ID) and ( name like ''%'+trim(combobox3.text)+'%''') ORDER BY roads.MAPINFO_ID'
 
s1:='select * from roads,do
orplate where (doorplate.ID = roads.ID) and ( name like '''%'+trim(combobox3.text)+'%''') ORDER BY roads.MAPINFO_ID'
不好 意思,刚刚少了一个'
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
2K
import
I
后退
顶部