You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by yiran9937 <yi...@sina.com> on 2015/07/09 10:00:59 UTC

got wrong data with using '%' as condition

Hi, I am Li. I started to learn to use the Derby no long time. I used derby
database in Eclipse and start connection with ij tool which in
derbytools.jar. The derby version is 10.9.Once, I select data from a table
with SQL "select * from tig_users where user_id like 'test_01_%';", but got
below data.
<http://apache-database.10148.n7.nabble.com/file/n144340/QQ%E6%88%AA%E5%9B%BE20150709161621.png>
Note the first record, the user_id 'test_01@yiranlocal' should not matching
with  'test_01_%', but I got it. I have no idea with this.I try to test this
with the newest version 10.11, but got the same result. What happened and
how can I get correct data result?I will very pleased for any
suggestion.Thanks and Regards,Li



--
View this message in context: http://apache-database.10148.n7.nabble.com/got-wrong-data-with-using-as-condition-tp144340.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

Re: got wrong data with using '%' as condition

Posted by yiran9937 <yi...@sina.com>.
Hi Kristian,
Thank you very much for your help. I got it with your suggestion.
I changed SQL to 'select * from tig_users where user_id like 'test_01=_%'
{escape '='};'  and got the results same as I want.
>From this case, I know that ij work with JDBC rule. It is very useful for my
next step to learn.
Thanks and Regards,
 Li




--
View this message in context: http://apache-database.10148.n7.nabble.com/got-wrong-data-with-using-as-condition-tp144340p144342.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

Re: got wrong data with using '%' as condition

Posted by Kristian Waagan <kr...@apache.org>.
Hi Li,

'_' is a wildcard character matching a single character. To search for the
literal '_' you have to escape it.

There may be several ways to do that, but one is described here:
https://db.apache.org/derby/docs/10.11/ref/rrefjdbc28456.html

Regards,
-- 
Kristian

tor. 9. jul. 2015, 18.56 skrev yiran9937 <yi...@sina.com>:

> Hi, I am Li. I started to learn to use the Derby no long time. I used
> derby database in Eclipse and start connection with ij tool which in
> derbytools.jar. The derby version is 10.9. Once, I select data from a table
> with SQL "select * from tig_users where user_id like 'test_01_%';", but got
> below data. Note the first record, the user_id 'test_01@yiranlocal'
> should not matching with 'test_01_%', but I got it. I have no idea with
> this. I try to test this with the newest version 10.11, but got the same
> result. What happened and how can I get correct data result? I will very
> pleased for any suggestion. Thanks and Regards, Li
> ------------------------------
> View this message in context: got wrong data with using '%' as condition
> <http://apache-database.10148.n7.nabble.com/got-wrong-data-with-using-as-condition-tp144340.html>
> Sent from the Apache Derby Users mailing list archive
> <http://apache-database.10148.n7.nabble.com/Apache-Derby-Users-f95095.html>
> at Nabble.com.
>