SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Deleting an item from a list

    I had a quick flick through MySQL's string functions here and the only thing I found close to what I want to do is the replace function.

    I have a field in my table which is numbers seperated by commas. An example would be:

    1,2,3,4,5,6

    If I wanted to update that field with one value removed is there a MySQL function to remove an item from a list, kind of the opposite to how FIND_IN_SET locates an item in a list ?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,022
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    not that i know of

    i think you'd have to use REPLACE()

    you'd have to be very careful, and make sure that when you remove 3, you don't accidentally remove 13 as well

    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah i'll just do all the work using PHP then. Although a function which did this would be a welcome addition to MySQL


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
  •