If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Joining Different Datatypes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-25-03, 17:38
xenovah xenovah is offline
Registered User
 
Join Date: Aug 2003
Posts: 1
Post Joining Different Datatypes

I'm pretty sure this answer is a 'no' but I wanted to post something just in case.

I'm working with a database that is a back-end for an application. For upgrade compatibility issues, I'm not allowed to alter the database in any fashion.

However, my boss asked me to create a query that relies on information from two different tables. The information I need (the keys unique to each of the rows) is in two different datatypes. The information is the same, but one table stores it as a number, the other as a varchar.

Is there any way to query the information I want joining these two datatypes? Or is there a procedure I can create that converts one column to the datatype I need?

Any help would be greatly appreicated. Thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 08-26-03, 06:14
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Re: Joining Different Datatypes

Quote:
Originally posted by xenovah
I'm pretty sure this answer is a 'no' but I wanted to post something just in case.

I'm working with a database that is a back-end for an application. For upgrade compatibility issues, I'm not allowed to alter the database in any fashion.

However, my boss asked me to create a query that relies on information from two different tables. The information I need (the keys unique to each of the rows) is in two different datatypes. The information is the same, but one table stores it as a number, the other as a varchar.

Is there any way to query the information I want joining these two datatypes? Or is there a procedure I can create that converts one column to the datatype I need?

Any help would be greatly appreicated. Thanks in advance.
The answer will be DBMS-specific, but it is possible to convert data from one datatype to another. In Oracle for example:

WHERE a.numcol = TO_NUMBER(b.charcol)

Beware that the TO_NUMBER would fail and raise an exception if any data in b.charcol was not convertible to a NUMBER.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On