From: Leandro S. <lea...@gm...> - 2008-10-01 18:41:16
|
On Wed, Oct 1, 2008 at 3:29 PM, Oleg Broytmann <ph...@ph...> wrote: > On Wed, Oct 01, 2008 at 03:19:14PM -0300, Leandro Sales wrote: >> SELECT * FROM domain WHERE LOCATE(name, hostname); > > Try: > > from sqlobject.sqlbuilder import func > Domain.select(func.LOCATE(Domain.q.name, hostname)) > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > I don't want to use LOCATE due to what I comment (in some cases it matches a wrong record for my case). I want the record of the Domain table that the field domain.name matches with the end of the variable 'hostname'. This works: qname = "www.domain1.com" domain = Domain.select("""'""" + qname + """' LIKE CONCAT('%', domain.name)""") The question is, is there a better way (more efficient) to do this using sqlobject? Thank you, Leandro. |