MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 19th, 2012, 05:13 AM
anusoosan anusoosan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 5 anusoosan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 46 sec
Reputation Power: 0
MySQL query with CONV function

table i used to execute the query is
_Count _FFID _VLD
-------------------------
1 0 1
2 3 1
3 1 1
4 2 1
5 e 1

*********SELECT _FFID FROM CsFFPCBValid WHERE CONV(_FFID,16,10) > 12

When i executed the query given above i got the result as

_FFID
------
e

But when i executed the query below , i got different result even though these have same meaning

*************SELECT _FFID FROM CsFFPCBValid WHERE CONV(_FFID,16,10) > CONV('c',16,10)

_FFID
------
3
2
e

Why it is so?

I am using mysql5.5.27 -win 32 version and Navicat as gui

Reply With Quote
  #2  
Old November 19th, 2012, 06:39 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 2,352 swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 4 Days 10 h 2 m 25 sec
Reputation Power: 390
conv returns a character value. The second comparsion will be between strings and the string '2' is greater than the string '12'.

In the first comparison, the result of conv will be implicitly casted as integer, thus comparing 2 > 12 which evaluates to false.

Reply With Quote
  #3  
Old November 19th, 2012, 09:25 AM
anusoosan anusoosan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 5 anusoosan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 46 sec
Reputation Power: 0
SELECT _FFID FROM CsFFPCBValid WHERE CONV(_FFID,16,16) > 0xc

gives the result
_FFID
------
0
3
1
2
e


this implicit casting is only in the case of integers?
How can i compare character value and hexadecimal value?

Reply With Quote
  #4  
Old November 19th, 2012, 11:38 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 2,352 swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 4 Days 10 h 2 m 25 sec
Reputation Power: 390
Code:
select _FFID
  from CsFFPCBValid
 where cast(CONV(_FFID,16,10) as signed) > cast(CONV('c',16,10) as signed)

Reply With Quote
  #5  
Old November 21st, 2012, 05:04 AM
anusoosan anusoosan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 5 anusoosan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 46 sec
Reputation Power: 0
thanks..

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > MySQL query with CONV function

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap