DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: in/like statement??

  1. #1
    Join Date
    Apr 2001
    Location
    London
    Posts
    725

    in/like statement??

    Hi Friends.

    can't work this out, maybe someone can help.

    I have the following query:

    SELECT i.item_sc, i.item_n, b.bldng_room_sc
    FROM item i, bldng_room b
    where i.bldng_room_id = b.bldng_room_id
    AND i.item_sc LIKE ('DIG00%','HUB00%','JET00%')

    obviously the like statement is not going to work as it should be an IN statememt however the values have a wildcard in them.

    can someone please help and tell me how to do this.

    thanks
    Once you have eliminated all of the impossible,
    whatever remains however improbable,
    must be true.

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    SELECT i.item_sc, i.item_n, b.bldng_room_sc
    FROM item i, bldng_room b
    where i.bldng_room_id = b.bldng_room_id
    AND
    (i.item_sc LIKE 'DIG00%' OR
    i.item_sc LIKE 'HUB00%' OR
    i.item_sc LIKE 'JET00%')
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  3. #3
    Join Date
    Apr 2001
    Location
    London
    Posts
    725
    Thanks.

    I tried that without the brackets and got thousands of results, all makes sense now.
    Once you have eliminated all of the impossible,
    whatever remains however improbable,
    must be true.

  4. #4
    Join Date
    Jan 2000
    Location
    Chester, England.
    Posts
    818
    or ...

    SELECT i.item_sc, i.item_n, b.bldng_room_sc
    FROM item i, bldng_room b
    where i.bldng_room_id = b.bldng_room_id
    AND SUBSTR(i.item_sc,1,5) IN ('DIG00','HUB00','JET00')


    (and lets assume item_sc isn't indexed!)

Posting Permissions

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


Click Here to Expand Forum to Full Width