changing value of the column only in selected entries

Discussion in 'MySQL' started by DFL, Jul 31, 2012.

  1. #1
    Hi,

    Here's my situation. I moved from wordpress to joomla, but i couldn't transfer categories. Now i have 4000 entries without categories. Can i select entries from the database and then change category field all at once for selected entries. I have around 30 different categories, so that how i could "recreate" all the categories with 30 goes.

    Hopefully my text wasn't too confusing.'

    Thanks,
    Risto
     
    DFL, Jul 31, 2012 IP
  2. DFL

    DFL Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    So i figured half out, i have a query like that:
    SELECT * FROM jos_content
    WHERE SUBSTRING( title, 1, 1 ) = 'A'
    SET catid = '12'
    LIMIT 0 , 5000

    But it doesnt work. So it should take all rows with title column starting with A and change the catid column to 12. But something went wrong. Any hep ?
     
    DFL, Aug 12, 2012 IP
  3. SitesTen

    SitesTen Active Member

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    75
    #3
    I believe it is possible to manually update the categories like this, but you should use an update instead of select. E.g. the next query will update all the entries in jos_content, starting with the letter a to a category with ID 12: UPDATE jos_content SET catid='12' WHERE title like 'A%'
     
    SitesTen, Aug 16, 2012 IP