I think that there's an extra "samples.description LIKE" in there (occurs twice).
But, should you want to do this with the ORM, assuming that samples is a model (or could be made one, see the legacy database stuff in the docs), I think that it could be done with Q objects using description__contains='ultraviolet' and title__contains='ultraviolet'. ....filter(description__contains= On Thu, Apr 29, 2010 at 6:12 PM, Daniel <unagimiy...@gmail.com> wrote: > Hi guys, > > I am having trouble getting multiple LIKE statements to work using > cursor.execute(SQL, [params]). > > Here is my raw SQL query which I have confirmed is working directly at > the mysql command line: > > "SELECT samples.number from samples WHERE samples.description LIKE > samples.description LIKE %ultraviolet% OR samples.title LIKE > %ultraviolet%" > > When I try to use cursor.execute() I am getting no matches. > > I am trying to construct the query above programmatically. Must I use > the query param? I know in the docs it states that it expects a > placeholder, but I don't want to use one. I have successfully > constructed the full query programmatically but that apparently > doesn't work and I don't know why. I use: > > cursor.execute("SELECT samples.number FROM samples WHERE %s",[query]) > > query = "samples.description LIKE samples.description LIKE %ultraviolet > % OR samples.title LIKE %ultraviolet%" > > I'd really appreciate some help. Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.