Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2005
    Posts
    71

    Unanswered: Is there a way to use wildcard characters...

    to reference columns.
    i have a table that has a column that is repeated 25 times, sort of.

    table_1
    tbl_ID (PK)
    tbl_c_1 char 5
    tbl_c_2 char 5
    tbl_c_3 char 5
    tbl_c_4 char 5
    tbl_c_5 char 5
    ....
    tbl_c_25 char 5

    everytime i want to query for any of tbl_c_? that contain a specific value i have to reference all 25 in my query. is there a better way?
    I cannot change the table.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Nope

    WHERE tbl_c_1 LIKE @x+'%'
    AND...
    AND tbl_c_25 LIKE @x+'%'


    Have fun

    scan o ramma
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    The problem is not in your code. The problem is in your database design.

    Your schema is not normalized. You need to store that data as separate records in a child table, rather than as distinct columns in the parent table. Then you search would be easy.

    Ineffecient coding is often the result of poor design.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Mar 2005
    Posts
    71
    i agree with you on that but unfortunately the one who created this mess for me is no longer working here. he left here for a better paying job doing the same thing, go figure. i am currently in the process of cleaning up this mess, about 30 of the tables his did the same thing and it will affect about 250+ programs. i was just hoping for a quick/temporary fix in the mean time.
    Thanks anyways all...

  5. #5
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Why not correct the table, and then create a view
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Could do that, but it would probably have to be an updatable view, as well as a crosstab, which means INSTEAD OF triggers, blah blah blah....
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    nah, ya think?

    Well, ok...the margaritas are starting to kick in

    Don't you feel bad for people stuck in these situations?

    Oh wait, that's me
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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