-3

谁能告诉我错误???

sql = ( select trim(last_name) as Last_Name, trim(first_name) as First_name, trim(middle_name) as Middle_Name,long_posname as Position from tb_crew_master join tb_position on (tb_position.posID = tb_crew_master.posID) where last_name like '%' . '%sname%' . '%')
4

2 回答 2

2

如果要使用赋值:=,则变量不需要%符号。如果你想使用赋值=,在这种情况下你必须使用 ` 作为转义字符。下面的 sql 和 sql2 行是相同的。

sname := "ThisName"
sql := "select trim(last_name) from tb_crew_master where last_name like '%" . sname . "%'"
sql2 = select trim(last_name) from tb_crew_master where last_name like '`%%sname%`%'
msgbox % sql "`n" sql2
于 2013-10-17T18:12:02.690 回答
1

我发现引号有问题,请尝试改进引号,如下

sql = ("select trim(last_name) as Last_Name, trim(first_name) as First_name,  
trim(middle_name) as Middle_Name,long_posname as Position 
from 
tb_crew_master 
join 
tb_position on (tb_position.posID = tb_crew_master.posID)
where 
last_name like '%".%sname%."%'")
于 2013-10-17T08:34:47.533 回答