python 数据查询语句如何限制查询条件的长度?
如下:比方下面这句我想限制Badge的长度为4位的如何限制??如何写加andBadgeselect*fromevw_empdaycardwhere(Termbetween...
如下:
比方下面这句我想限制Badge的长度为4位的如何限制??如何写加 and Badge
select * from evw_empdaycard where (Term between '2014-11-01 00:00:00' and '2014-11-17 00:00:00') and depnam2 = 'Test'
但是在代码中用以下句子就会报错,加上and length(Badge)=4这个条件就会报错:
sql = "select Term,EWCS from evw_empdaycard where (Term between '"+beginTime+"' and '"+endTime+"') and depnam2 = 'Test' and length(Badge)=4 "
ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Ser
ver]'length' \xb2\xbb\xca\xc7\xbf\xc9\xd2\xd4\xca\xb6\xb1\xf0\xb5\xc4 \xc4\xda\x
d6\xc3\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6\xa1\xa3 (195) (SQLExecDirectW)") 展开
比方下面这句我想限制Badge的长度为4位的如何限制??如何写加 and Badge
select * from evw_empdaycard where (Term between '2014-11-01 00:00:00' and '2014-11-17 00:00:00') and depnam2 = 'Test'
但是在代码中用以下句子就会报错,加上and length(Badge)=4这个条件就会报错:
sql = "select Term,EWCS from evw_empdaycard where (Term between '"+beginTime+"' and '"+endTime+"') and depnam2 = 'Test' and length(Badge)=4 "
ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server Driver][SQL Ser
ver]'length' \xb2\xbb\xca\xc7\xbf\xc9\xd2\xd4\xca\xb6\xb1\xf0\xb5\xc4 \xc4\xda\x
d6\xc3\xba\xaf\xca\xfd\xc3\xfb\xb3\xc6\xa1\xa3 (195) (SQLExecDirectW)") 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询