Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread spondbob squelpen
I tried to make it simple like this: placeTag = "'\%"+placeTag+"\%'" ... query = r""" ... WHERE placeType_id = %s AND placeTag LIKE %s ... """ The query string is correct: WHERE placeType_id = 1 AND placeTag like '\%tes\%' But i got no result in django. When i execute it in mysql client i got re

Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread spondbob squelpen
i tried swap the WHERE condition become like this: WHERE %s placeType_id=%s \ and tags: tags = " (placeTag LIKE '%" + "%' OR placeTag LIKE '%".join(placeTag.split(',')) + "%') AND " but got this error: DatabaseError: (1064, "You have an error in your SQL syntax; check the manual that correspond

Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread spondbob squelpen
I've tried the debugger but i have no idea how to use it to find my problem. in Pdb console i've tried check any variable value and everything seems fine On Wednesday, July 17, 2013 10:34:39 PM UTC+7, larry@gmail.com wrote: > > On Wed, Jul 17, 2013 at 9:28 AM, spondbob squelpen > > > wrote

Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread Larry Martell
On Wed, Jul 17, 2013 at 8:58 AM, spondbob squelpen wrote: > where do i put those double percentage? like this? > tags = " AND (placeTag LIKE '%%" + "%%' OR placeTag LIKE > '%%".join(placeTag.split(',')) + "%%')" > > but still got the same error: > Warning: Truncated incorrect DOUBLE value: '1 AND

Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread Larry Martell
On Wed, Jul 17, 2013 at 8:24 AM, spondbob squelpen wrote: > I have problem in django using query statement "like %s%" with > Model.objects.raw(). I guess the problem is on '%' character but i don't > know where is it. Here's my model's code: > > def listInRange(self, placeLat, placeLng, typeId

Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread spondbob squelpen
sorry i'm new with django, could u please tell me how to use the debugger? On Wednesday, July 17, 2013 10:17:10 PM UTC+7, larry@gmail.com wrote: > > On Wed, Jul 17, 2013 at 9:15 AM, spondbob squelpen > > > wrote: > > the '1' is coming from typeId, so the WHERE condition must be look like:

Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread Larry Martell
On Wed, Jul 17, 2013 at 9:28 AM, spondbob squelpen wrote: > sorry i'm new with django, could u please tell me how to use the debugger? In your python code, add this "import pdb; pdb.set_trace()' at the place you want the breakpoint. Then run: python manage.py runserver Then go to your web page

Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread Larry Martell
On Wed, Jul 17, 2013 at 9:15 AM, spondbob squelpen wrote: > the '1' is coming from typeId, so the WHERE condition must be look like: > WHERE placeType_id=1 AND (placeTag LIKE '%test%') > > print out tags: > AND (placeTag LIKE '%test%') > > i have tried your solution by adding double percentage b

Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread spondbob squelpen
the '1' is coming from typeId, so the WHERE condition must be look like: WHERE placeType_id=1 AND (placeTag LIKE '%test%') print out tags: AND (placeTag LIKE '%test%') i have tried your solution by adding double percentage but still got same error On Wednesday, July 17, 2013 10:04:48 PM UTC+7

Re: 'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread spondbob squelpen
where do i put those double percentage? like this? tags = " AND (placeTag LIKE '%%" + "%%' OR placeTag LIKE '%%".join(placeTag.split(',')) + "%%')" but still got the same error: Warning: Truncated incorrect DOUBLE value: '1 AND (placeTag LIKE '%%test%%')' On Wednesday, July 17, 2013 9:47:25 PM

'LIKE' statement in Model.objects.raw() with percentage '%'

2013-07-17 Thread spondbob squelpen
I have problem in django using query statement "like %s%" with Model.objects.raw(). I guess the problem is on '%' character but i don't know where is it. Here's my model's code: def listInRange(self, placeLat, placeLng, typeId, range, placeTag): tags = '' if placeTag: