Unix Technical Forum

Weird Results (found w/LIKE, but not with exact match)

This is a discussion on Weird Results (found w/LIKE, but not with exact match) within the MySQL forums, part of the Database Server Software category; --> There is some strange behaviour with one of my tables in MySQL. When I perform a query with an ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 08:32 AM
yankeerivera@yahoo.com
 
Posts: n/a
Default Weird Results (found w/LIKE, but not with exact match)

There is some strange behaviour with one of my tables in MySQL. When I
perform a query with an exact match, the result set comes back empty.
When I run it with a LIKE clause, I get some results.

Does Not Work:

mysql -u prod -h mysqlsrv ws_history_stg -e "SELECT * FROM MSG WHERE
ORDER_REF = '20061108/RAPTEST/RDL611004643' ORDER BY LOG_TIMESTAMP"

Works:

mysql -u prod -h mysqlsrv ws_history_stg -e "SELECT * FROM MSG WHERE
ORDER_REF LIKE '20061108/RAPTEST/RDL611004643%' ORDER BY LOG_TIMESTAMP"

There is certainly 1 record in MSG where MSG.ORDER_REF =
'20061108/RAPTEST/RDL611004643'

Why should MySQL not return it for the first query?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 08:32 AM
Harald Fuchs
 
Posts: n/a
Default Re: Weird Results (found w/LIKE, but not with exact match)

In article <1163105789.314191.279110@h54g2000cwb.googlegroups .com>,
yankeerivera@yahoo.com writes:

> There is certainly 1 record in MSG where MSG.ORDER_REF =
> '20061108/RAPTEST/RDL611004643'


> Why should MySQL not return it for the first query?


Probably because your order_ref ends with some whitespace.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 08:32 AM
yankeerivera@yahoo.com
 
Posts: n/a
Default Re: Weird Results (found w/LIKE, but not with exact match)


Harald Fuchs wrote:
> In article <1163105789.314191.279110@h54g2000cwb.googlegroups .com>,
> yankeerivera@yahoo.com writes:
>
> > There is certainly 1 record in MSG where MSG.ORDER_REF =
> > '20061108/RAPTEST/RDL611004643'

>
> > Why should MySQL not return it for the first query?

>
> Probably because your order_ref ends with some whitespace.


Yes, I thought so, but that is not the case. I dumped the whole table
to a file and I checked. The value _is_ present and it does _not_
contain any leading or trailing whitespaces.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 08:32 AM
Radoulov, Dimitre
 
Posts: n/a
Default Re: Weird Results (found w/LIKE, but not with exact match)


>> > There is certainly 1 record in MSG where MSG.ORDER_REF =
>> > '20061108/RAPTEST/RDL611004643'

>>
>> > Why should MySQL not return it for the first query?

>>
>> Probably because your order_ref ends with some whitespace.

>
> Yes, I thought so, but that is not the case. I dumped the whole table
> to a file and I checked. The value _is_ present and it does _not_
> contain any leading or trailing whitespaces.


.... or may be some non printable character(s),
check with:

select length(ORDER_REF) from MSG;

or

use cat -v on your dump file.


Regards
Dimitre


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:01 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com