Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Question Unanswered: select with wildcards

    Hi,

    I'm trying to write a SELECT query (in Oracle) that mimics a join of two tables. However, instead of matching values exactly, it looks for values of one table that are substrings of another table's column's values.

    Basically, I envision the query to have the following form:

    SELECT a.name1, b.name2
    FROM a, b
    WHERE name1 like %name2%

    The problem is that the '%' symbols cause Oracle to throw an error.

    If you know of another way of writing such a query, please let me know!

    Thanks in advance,
    Yariv

  2. #2
    Join Date
    Jan 2004
    Posts
    492

    Re: select with wildcards

    Originally posted by yarivvv
    Hi,

    I'm trying to write a SELECT query (in Oracle) that mimics a join of two tables. However, instead of matching values exactly, it looks for values of one table that are substrings of another table's column's values.

    Basically, I envision the query to have the following form:

    SELECT a.name1, b.name2
    FROM a, b
    WHERE name1 like %name2%

    The problem is that the '%' symbols cause Oracle to throw an error.

    If you know of another way of writing such a query, please let me know!

    Thanks in advance,
    Yariv

    Not sure if you know the substring sections but you could do something like:

    Code:
    SELECT
    a.name1, b.name2
    from a,b
    where a.name1 = substr(b.name2, 1, 10)

  3. #3
    Join Date
    Mar 2004
    Posts
    2
    thanks!

  4. #4
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    select *
    from
    tableA a
    INNER JOIN
    tableB b ON
    a.name LIKE '%'||b.name||'%';
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Posting Permissions

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