query question

  • i have 2 columns i need to compare them, the data is close to equal but one has a prefix

    example:

    tbl_a , tbl_b

    LINK_100, 100

    here is my query

    select * from tbl_a where a_id in ('select b_id from tbl_b')

    can i input LINK_ somewhere to make the columns equal?

    I cannot alter the tables data

    thanks for viewing

  • What is in the actual data?

    The prefix 'link_'

    or an actual dynamic [web page] link?

     

    Some actual sample data would greatly help us generate the adequate solution.

  • the table names are

    tbl_a , tbl_b

    and the columns are

    LINK_100, 100

    LINK_101, 101

  • select a.* from tbl_a a inner join tbl_b b on REPLACE(a_id, 'LINK_', '') = b.b_id

  • perfect that worked like a charm

    thank you for your help

  • Could also do the following:

     

    select * from Tbla

    join tblb

    on tbla.id = 'Link_' + tblb.id

     

     


    If you don't stand for something, you'll fall for anything!,

    Don Urquhart

  • Or:

    select a.* from tbl_a a inner join tbl_b b on RIGHT(a.col1,3) = b.col1

    -SQLBill

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply