作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我在 python 中有这个查询:
ssim_group = [S1200,S1300]
query = '''select WIPMessageCnt from waferdata where recipename in (%s) and equipment = ?
and runtype = ? order by stopts desc limit 1''' % (','.join(ssim_grp))
打印查询
当前结果
select WIPMessageCnt from waferdata where recipename in (S1200,S1460) and equipment = ? and runtype = ? order by stopts desc limit 1
预期结果应该是这样的
select WIPMessageCnt from waferdata where recipename in ('S1200','S1460') and equipment = ? and runtype = ? order by stopts desc limit 1
当我尝试将它们放入 SQL 的 IN 参数中时,列表应该对每个元素进行单引号。我怎样才能做到这一点?
最佳答案
ssim_group = ['S1200', 'S1300']
query = '''select WIPMessageCnt from waferdata where recipename in ('%s') and equipment = ? and runtype = ? order by stopts desc limit 1''' % ("','".join(ssim_group))
关于字符串到 SQL IN 参数的 Python 列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34897802/
我是一名优秀的程序员,十分优秀!