<!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:&nbsp; </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>&nbsp;</DIV>
<DIV><FONT color=#000080>for row in con.execute("SELECT &lt;column&gt; FROM 
&lt;table&gt; WHERE &lt;string&gt; LIKE '%q%' limit 25"):<BR></FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV>... where &lt;column&gt;, &lt;table&gt;, &lt;string&gt; are 
placeholders!</DIV>
<DIV>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT color=#000080>Cheers!</FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080>Dinesh</FONT></DIV></FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</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.&nbsp; 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>&nbsp;</DIV>
<DIV><FONT color=#000080>&gt; (u'QB VII',)<BR>&gt; (u'Quackser Fortune Has a 
Cousin in the Bronx',)</FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</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>&nbsp;</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.&nbsp; For 
example, looking for the characters q='dog' in each string the SELECT statement 
is as follows:</FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080>for row in con.execute("SELECT &lt;column&gt; FROM 
&lt;table&gt; WHERE &lt;string&gt; LIKE '%q%' limit 25"):<BR>&nbsp;&nbsp;&nbsp; 
print row</FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080>This doesn't work and I've tried other combinations 
without luck!&nbsp; Any thoughts on the correct syntax for the 
LIKE?</FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV>
<DIV><FONT color=#000080>Dinesh</FONT></DIV>
<DIV><FONT color=#000080></FONT>&nbsp;</DIV></BODY></HTML>