I have this query in 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))
print query
Current result
select WIPMessageCnt from waferdata where recipename in (S1200,S1460) and equipment = ? and runtype = ? order by stopts desc limit 1
Expected result should be like this
select WIPMessageCnt from waferdata where recipename in ('S1200','S1460') and equipment = ? and runtype = ? order by stopts desc limit 1
The list should have single qoutation on each element when I try to put them inside the IN parameter on SQL. How can I achieve this?
asked Jan 20, 2016 at 10:43
ellaRT
1,3862 gold badges19 silver badges42 bronze badges
1 Answer 1
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))
Sign up to request clarification or add additional context in comments.
1 Comment
Nikhil Talreja
this does not work if string has a quote like
['S1200', "S1300's"]default
...WHERE FIND_IN_SET(recipename, %s) > 0...