鱼C论坛

 找回密码
 立即注册
查看: 1873|回复: 1

关于SQL查询的问题

[复制链接]
发表于 2020-4-18 17:42:03 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import pymssql
  2. PL ='ooA5'
  3. Stock = '1,2,3,4'
  4. conn = pymssql.connect(server='AA', user='sa', password='FF', database='CC',
  5.                                charset='utf8')
  6. sql = "select a.productID,fullName,b.storageName," \
  7.       "convert(int,isnull(d.orderAmount,0)) as orderAmount," \
  8.       "convert(int,isnull(d.roadamount,0)) as roadamount," \
  9.       "convert(int,isnull(d.amount,0)) as amount," \
  10.       "convert(int,isnull(d.money,0)) as money " \
  11.       "from EIM_BSS_Basic_Products a cross join " \
  12.       "EIM_BSS_Basic_Storage b join " \
  13.       "EIM_BSS_Stat_ProductStorage c on a.productID=c.productID Left join " \
  14.       "EIM_BSS_Stat_ProductSubStorage d on a.productID=d.productID and b.storageID=d.storageID Left join " \
  15.       "EIM_BSS_Basic_ProductCategories e on a.productCategoryID=e.productCategoryID Left join " \
  16.       "EIM_BSS_Basic_ProductCategories f on left(a.productCategoryID,4)=f.productCategoryID " \
  17.       "where left(a.productCategoryID,4) = %s and b.storageid in (%s)" \
  18.       "order by fullName ,left(a.productCategoryID,4),a.productCategoryID,a.productid,b.storageID"
  19. cursor0 = conn.cursor()  # 创建游标0
  20. cursor0.execute(sql,(PL,Stock))  # 执行sql
  21. sqlData = cursor0.fetchall()
  22. cursor0.close()
  23. conn.close()
  24. print(sqlData)
复制代码


谁能帮忙解释下为什么一直错吗?放入一个参数就可以,2个就不行了。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-4-18 17:52:11 From FishC Mobile | 显示全部楼层
这款sql没用过,建议你先在数据库环境里通过
或者navicat里也能测试
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-30 14:01

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表