撷思、 2023-04-12 21:20 采纳率: 0%
浏览 20

python如何动态拼接sql

传入多个查询参数时,某些情况下,只使用到其中一个或两个,这种情况下怎么动态的拼接出sql

  • 写回答

1条回答 默认 最新

  • threenewbee 2023-04-12 22:18
    关注

    and的拼接
    select * from table where 1=1
    每次拼接 and xxx=xxx
    or拼接
    (select * from table where xxx=xxx) union (select * from table where yyy=yyy) ...

    评论

报告相同问题?

问题事件

  • 创建了问题 4月12日