<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.6000.16640" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT color=#000080>
<DIV><FONT color=#000080>Try again: </FONT></DIV>
<DIV><FONT color=#000080>I'm using the LIKE operator to match a pattern against
a string using this SELECT statement:</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>for row in con.execute("SELECT <column> FROM
<table> WHERE <string> LIKE '%q%' limit 25"):<BR></FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV>... where <column>, <table>, <string> are
placeholders!</DIV>
<DIV> </DIV>
<DIV>With q="dog" as a test example, I've tried '$q%', '%q%', '%q' and 'q%' and
none of them return what I expect ie. all strings with the characters "dog" in
them.</DIV>
<DIV> </DIV>
<DIV><FONT color=#000080>Cheers!</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>Dinesh</FONT></DIV></FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV style="FONT: 10pt arial">----- Original Message -----
<DIV style="BACKGROUND: #e4e4e4; font-color: black"><B>From:</B> <A
title=dineshbvadhia@hotmail.com href="mailto:dineshbvadhia@hotmail.com">Dinesh B
Vadhia</A> </DIV>
<DIV><B>To:</B> <A title=tutor@python.org
href="mailto:tutor@python.org">tutor@python.org</A> </DIV>
<DIV><B>Sent:</B> Thursday, April 10, 2008 3:24 PM</DIV>
<DIV><B>Subject:</B> SQLite LIKE question</DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT color=#000080>I'm reading a text file into an in-memory pysqlite
table. When I do a SELECT on the table, I get a 'u' in front of each
returned row eg.</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>> (u'QB VII',)<BR>> (u'Quackser Fortune Has a
Cousin in the Bronx',)</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>I've checked the data being INSERT'ed into the table
and it has no 'u'.</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>The second problem is that I'm using the LIKE operator
to match a pattern against a string but am getting garbage results. For
example, looking for the characters q='dog' in each string the SELECT statement
is as follows:</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>for row in con.execute("SELECT <column> FROM
<table> WHERE <string> LIKE '%q%' limit 25"):<BR>
print row</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>This doesn't work and I've tried other combinations
without luck! Any thoughts on the correct syntax for the
LIKE?</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV>
<DIV><FONT color=#000080>Dinesh</FONT></DIV>
<DIV><FONT color=#000080></FONT> </DIV></BODY></HTML>