mysql 的“instr"函数的 Web2py 的“包含"函数 [英] Web2py's 'contains' function for 'instr' function of mysql
本文介绍了mysql 的“instr"函数的 Web2py 的“包含"函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个对我来说很好用的 mysql 查询
I have this mysql query which works fine for me
select * from mc,mcex
where instr(mcex.example,mc.element)
我在 web2py 中为此编写了以下代码,如下所示:
I have written following code in web2py for this as given below:
rows=db(db.mcex.example.contains(db.mc.element)).select()
它不工作.请帮忙.
推荐答案
使用 web2py DAL,查询(生成 SQL WHERE
子句)可以只是一串 SQL 代码,因此您可以做:
Using the web2py DAL, the query (which generates the SQL WHERE
clause) can simply be a string of SQL code, so you can do:
rows = db('instr(mcex.example, mc.element)').select(db.mcex.ALL, db.mc.ALL)
更新:
如果您需要查询条件的组合,您可以通过链接Set
对象调用来实现:
If you need a conjunction of conditions for the query, you can do so by chaining Set
object calls:
rows = db(query1)(query2)('instr(mcex.example, mc.element)').select(
db.mcex.ALL, db.mc.ALL)
这篇关于mysql 的“instr"函数的 Web2py 的“包含"函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文