sql - openerp : using the value of a variable in where clause

标签 sql postgresql odoo

abe= []
abibiti=1
self.cr.execute("SELECT name FROM account_analytic_account where parent_id=abibiti")                
for t in self.cr.fetchall():
for item in t:
    abe.append(item)

我想使用变量“abbiti”的值来检查 where 子句,谁能帮帮我

最佳答案

您在 cr.execute 中编写查询的方式存在一些问题。请将其更改为:

abe= []
abibiti=1
cr.execute("SELECT name FROM account_analytic_account where parent_id=%s"%(abibiti))                
for t in cr.fetchall():
    for item in t:
        abe.append(item)

关于sql - openerp : using the value of a variable in where clause,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19635142/

相关文章:

database - Odoo 数据库在端口更改后不加载

python - 如何在以下功能中使用电子邮件模板?

mysql - 多个帐户的总和值

sql - Scala,元组的sql插值

php - ON DUPLICATE KEY 忽略 ID

json - 如何将 JSON 提取到表中

node.js - [ :^punct] 的 Postgresql 无效类

css - 条件格式 Odoo 表单 View

mysql - 有没有办法在没有第二次查询的情况下执行此条件 JOIN?

sql - 从 3 个表中获取数据时的 Db2 查询