Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    362

    Unanswered: values separated by ',' and query values

    I have a table
    mytable
    that have a field
    myfield
    with values separated by ',' .
    I want to make a query that return values some spesific values (more than one) of
    myfield
    (example 3,4 or 3 or 3,4,5).
    Which is the best way to do that?
    Dimis

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Most people try to get their data in to 3NF. Your data is not even in 1NF which is why you're having problems. I'd suggest reading up a bit on normal forms and then just altering your table to hold each value separately ie

    Code:
    # original string "aaa,bbb,,ddd,eee"
    
    insert mytable ( seq, myfield ) values ( 1, "aaa" );
    insert mytable ( seq, myfield ) values ( 2, "bbb" );
    insert mytable ( seq, myfield ) values ( 4, "ddd" );
    ...
    Then all you have to write is
    Code:
    select myfield from mytable where seq in (1,2,3)
    Mike

Posting Permissions

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