Professional Web Applications Themes

Use 'Like' with a field name instead os a string - Microsoft SQL / MS SQL Server

Hello all, I have a problem which i can't find the answer to. I have 2 tables, with a comparable field. Example: TableA.Program,etc. TableB.ProgFileName,etc. i want to make a join query on a PART of Progfilename to be equal to ALL Program. I tried: SELECT TableA.Program FROM TableA CROSS JOIN TableB WHERE TableB.filename LIKE %TableA.Program% But i think this is invalid, as Like is said to get only string patterns. I can't use left or mid, as the letters can be anywhere in the field. If neccessary i can make another field in the tableA with only the letters i ...

  1. #1

    Default Use 'Like' with a field name instead os a string

    Hello all,

    I have a problem which i can't find the answer to.

    I have 2 tables, with a comparable field.
    Example:
    TableA.Program,etc.
    TableB.ProgFileName,etc.

    i want to make a join query on a PART of Progfilename to be equal to ALL
    Program. I tried:

    SELECT TableA.Program
    FROM TableA CROSS JOIN
    TableB
    WHERE TableB.filename LIKE %TableA.Program%

    But i think this is invalid, as Like is said to get only string patterns.

    I can't use left or mid, as the letters can be anywhere in the field.

    If neccessary i can make another field in the tableA with only the
    letters i need to crossjoin, but i' rather not.

    Any help will be gratefully accepted ;)
    rotem ben-Israel Guest

  2. #2

    Default Re: Use 'Like' with a field name instead os a string

    Hi

    Try

    SELECT A.Program
    FROM TableA A CROSS JOIN TableB B
    WHERE B.filename LIKE '%' + A.Program + '%'

    John

    "rotem ben-Israel" <rotem.ben-israelintel.com> wrote in message
    news:79665e3a.0305050210.151b6e01posting.google.c om...
    > Hello all,
    >
    > I have a problem which i can't find the answer to.
    >
    > I have 2 tables, with a comparable field.
    > Example:
    > TableA.Program,etc.
    > TableB.ProgFileName,etc.
    >
    > i want to make a join query on a PART of Progfilename to be equal to ALL
    > Program. I tried:
    >
    > SELECT TableA.Program
    > FROM TableA CROSS JOIN
    > TableB
    > WHERE TableB.filename LIKE %TableA.Program%
    >
    > But i think this is invalid, as Like is said to get only string patterns.
    >
    > I can't use left or mid, as the letters can be anywhere in the field.
    >
    > If neccessary i can make another field in the tableA with only the
    > letters i need to crossjoin, but i' rather not.
    >
    > Any help will be gratefully accepted ;)

    John Bell Guest

Similar Threads

  1. P a string from a field and display in table
    By Dan Somdahl in forum ASP Components
    Replies: 1
    Last Post: April 19th, 09:35 PM
  2. #39134 [NEW]: PHP + FreeTDS 0.64 crashes when TEXT field with empty string encountered
    By jr-phpbugs at cedric dot unob dot cz in forum PHP Bugs
    Replies: 6
    Last Post: November 1st, 09:49 AM
  3. String to mysql date field
    By Noyb in forum PHP Development
    Replies: 3
    Last Post: May 16th, 09:59 PM
  4. Select from table where field = string
    By Michel in forum PHP Development
    Replies: 6
    Last Post: August 24th, 06:35 PM
  5. Replies: 3
    Last Post: August 15th, 10:52 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139