<div dir="ltr">Hi Ken,<br><br>This works for me - did you try the obvious?<br><div><br>$resultset->search({ name => { 'like' => '%\_%' } } )<br><br>cheers,<br>Bob<br><br><br></div><div><br></div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 18, 2014 at 7:24 PM, Kenneth Ölwing <span dir="ltr"><<a href="mailto:kenneth@olwing.se" target="_blank">kenneth@olwing.se</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
I happen to have text data in my table that has the '_' (underscore) character, and I wanted to do a like search.<br>
<br>
So to find all rows with '_' I did:<br>
<br>
my @rows = $rs->search( { data => { like => '%_%' } } );<br>
<br>
and running with DBIC_TRACE=1, I see:<br>
<br>
SELECT me.data FROM test me WHERE ( data LIKE ? ): '%_%'<br>
<br>
I didn't get the result I was expecting. And duh, it dawned on me that '_' is itself a wildcard char...<br>
<br>
After realising that, I researched and found out that I could write something like this (a direct query):<br>
<br>
SELECT * FROM test WHERE (data LIKE '%\_%' ESCAPE '\');<br>
<br>
Being a beginner with DBIx::Class, I may not have found the right place to look, but so far no luck...can I achieve this effect with the Perl code, and if so how? I'm using SQLite for the moment and Perl 5.16 and latest DBIx::Class.<br>
<br>
TIA, any help appreciated.<br>
<br>
ken1<br>
<br>
<br>
-----<br>
No virus found in this message.<br>
Checked by AVG - <a href="http://www.avg.com" target="_blank">www.avg.com</a><br>
Version: 2014.0.4716 / Virus Database: 3986/7876 - Release Date: 07/18/14<br>
<br>
<br>
______________________________<u></u>_________________<br>
List: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class" target="_blank">http://lists.scsys.co.uk/cgi-<u></u>bin/mailman/listinfo/dbix-<u></u>class</a><br>
IRC: <a href="http://irc.perl.org#dbix-class" target="_blank">irc.perl.org#dbix-class</a><br>
SVN: <a href="http://dev.catalyst.perl.org/repos/bast/DBIx-Class/" target="_blank">http://dev.catalyst.perl.org/<u></u>repos/bast/DBIx-Class/</a><br>
Searchable Archive: <a href="http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk" target="_blank">http://www.grokbase.com/group/<u></u>dbix-class@lists.scsys.co.uk</a><br>
</blockquote></div><br></div>