On Wed, Oct 1, 2008 at 3:19 PM, Leandro Sales <[EMAIL PROTECTED]> wrote: > I'd like a sqlobject query that does: > > Domain table: > id name > 1 domain1.com > 2 domain2.com > 3 domain3.com > > hostname = 'www.domain1.com' > > SELECT * FROM domain WHERE hostname LIKE CONCAT('%', name); > > or in a similar way: > > SELECT * FROM domain WHERE LOCATE(name, hostname); > > The problem in the second approach (though I think it is more > efficient and the first one), is if the variable hostname is > "www.domain1.com.br", the query is still valid, but it shouldn't be. > > So, what is the best way to do what I need? > > Thank you, > Leandro. > > > On Wed, Oct 1, 2008 at 2:59 PM, Oleg Broytmann <[EMAIL PROTECTED]> wrote: >> On Wed, Oct 01, 2008 at 02:34:16PM -0300, Leandro Sales wrote: >>> On Tue, Sep 30, 2008 at 7:19 PM, Leandro Sales <[EMAIL PROTECTED]> wrote: >>> > but instead, I'd check which domain name is in the hostname. Somethink >>> > like: >>> > >>> > domain = >>> > Domain.select("www.domain1.com".endswith(Domain.q.name.endswith())) >> >> I don't understand what query you are going to build. Can you elaborate? >> >> Oleg.
Hello, I did: qname = "www.domain1.com" domain = Domain.select("""'""" + qname + """' LIKE CONCAT('%', domain.name)""") Is there a better way to do this? Thank you, Leandro. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss