Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2009
    Posts
    17

    Unanswered: 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 !!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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

    Last edited by r937; 07-01-09 at 11:04.
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    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.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  5. #5
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    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/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •