您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

SQL Python,处理 Where 语句中的一个或多个值

SQL Python,处理 Where 语句中的一个或多个值

实施该更改后,我没有收到 Numpy 错误,而是格式错误。所以做了下面的改动

filename = 'test.csv'
division = test.iloc[0][4]
division_tuple = tuple(map(int, str(division).split(",")))


sql = cs.execute("""
INSERT INTO sample_table_name
select c.customer_id,
c.customer_name
from(
t.customer_id
t.customer_name


from customer_table t

where division_id in (%s) --changed format here 
group by 1,2) c ;
""",(division_tuple)) #and here 

虽然这在技术上会使 where 子句在只有一个值时看起来像“where Division_id in (92,)”,但这仍然是运行它的正确方法,尽管在 92 之后有尾随逗号。

SQLServer 2022/1/1 18:52:52 有340人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶