concatinate - help please

Discussion in 'MySQL' started by stock_post, Apr 11, 2011.

  1. #1
    I have url field without "http://"

    so, I am trying to run an update query as stated below..

    Please see if you can help me with the syntax

    -----------
    update `v2302_listings`
    set `v2302_listings`.`url' = concat(’http://’, `v2302_listings`.`url')
    where status ='Approval'
     
    stock_post, Apr 11, 2011 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    My guess is that the backticks are causing the problems. I would do it like this:

    UPDATE v2302_listings
    SET url = concat('http://', url)
    WHERE status ='Approval'

    You only need to use backticks if one of your columns is named a Mysql reserved word. Like if you have a column named Date, you should reference the column using `Date` so that the database isn't thinking you are trying to call the function Date(). Otherwise they tend to complicate things.
     
    jestep, Apr 12, 2011 IP
  3. stock_post

    stock_post Prominent Member

    Messages:
    5,213
    Likes Received:
    249
    Best Answers:
    0
    Trophy Points:
    310
    #3
    Thanks, that worked - I know Oracle but mySql is something I don't use that much.
     
    stock_post, Apr 14, 2011 IP