Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2008
    Posts
    7

    Lightbulb Unanswered: Using where like

    Hello,

    I have two tables..

    The first has a column whith data like this:

    A99999

    the second has a column whith data like this:

    XXX0000/Zxy_A99999_1234

    I want to select data from the second table using the first table, something like this:

    select * from second where second.column like '%first.column%'

    Any sugestion how can i do that?

    I'm using informix..

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    in ANSI SQL, you would use this --
    Code:
    WHERE second.column LIKE '%' || first.column || '%'
    by the way, did you know we have an Informix forum?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    I don't know what functions Informix has available but I would look for one that can locate a character string in another string.

    In DB2 it would be something like:

    WHERE LOCATE(COL1, COL2) > 0

    This would search for the value of COL1 (A99999) in COL2(XXX0000/Zxy_A99999_1234) and return the starting position of that value. A 0 indicates it is not found so "> 0" indicates it was in the string. If you have that function it may be called something else.

  4. #4
    Join Date
    Dec 2008
    Location
    At work...
    Posts
    92
    ANSI/ISO SQL has POSITION:

    <string position expression> ::=
    POSITION <left paren> <string value expression>
    IN <string value expression> <right paren>


    e.g ...WHERE POSITION(COL1 IN COL2) > 0

  5. #5
    Join Date
    Mar 2008
    Posts
    7
    Quote Originally Posted by r937
    in ANSI SQL, you would use this --
    Code:
    WHERE second.column LIKE '%' || first.column || '%'
    by the way, did you know we have an Informix forum?


    tks man, worked!

Posting Permissions

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