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 > How can i compare smallint and int

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-01-09, 09:37
Vaibhav Vyas Vaibhav Vyas is offline
Registered User
 
Join Date: Jul 2009
Posts: 17
How can i compare smallint and int

hi

In source i have smallint data type and in destination i have integer data type..

So how i can compare that?

Thanks in Advance !!
Reply With Quote
  #2 (permalink)  
Old 07-01-09, 10:00
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,511
Quote:
Originally Posted by Vaibhav Vyas
So how i can compare that?
Code:
SELECT ...
  FROM source
INNER
  JOIN destination
    ON destination.somecolumn = source.comecolumn
 WHERE source.smallintcolumn = destination.integercolumn
the WHERE clause will evaluate as TRUE or FALSE depending on whether the comparison is equal or not equal

this query will therefore return all matching rows where they are equal

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Last edited by r937; 07-01-09 at 10:04.
Reply With Quote
  #3 (permalink)  
Old 07-01-09, 10:09
Vaibhav Vyas Vaibhav Vyas is offline
Registered User
 
Join Date: Jul 2009
Posts: 17
hahi Thanks for this...

But up to i know we can't use where clause just after the ON ..

If i am wrong please let me know.
Reply With Quote
  #4 (permalink)  
Old 07-01-09, 10:19
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Rudy posted regular standard SQL. So what do you mean with "you can't use a WHERE clause after the ON"? The ON ... is part of a joined table. A joined table is part of the FROM clause, and following the FROM clause may come a WHERE clause. So the ON and the WHERE are actually not related at all and orthogonal concepts.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 07-02-09, 17:01
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,076
Quote:
Originally Posted by Vaibhav Vyas
In source i have smallint data type and in destination i have integer data type..
So how i can compare that?
If there would be any incompatibility whatsoever, you may use
Code:
CAST(value_smallint AS integer)
instead of just value_smallint

HTH
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
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