SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist priti's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    query help -split in mysql

    Consider

    fieldname=code
    ------
    508/774
    508/774/978
    508/774/781/978

    i want 508,774,978,781 thru mysql query .Is it possible because if i use DISTICT it show all options with 508 .

    Thanks

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Don't know if it's possible, but if this is a field that contains concatenated values, then you'd better normalize this table. After that, querying will be much easier.

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,262
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    it's possible, but it's horribly complicated

    basically it uses trickery to generate one new row for every value, then uses DISTINCT on them

    you should do as guido says, normalize the data so that it's actually stored as one row per value
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Evangelist priti's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is already in very mature state...i knew it will not be easy so i handled at application level :-)

    Thanks buddies


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
  •