Thread: UPDATE syntax

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Location
    Pierrefonds, QC Canada
    Posts
    205
    Rep Power
    11

    UPDATE syntax


    Hi there!

    In phpMyAdmin, I wrote unsuccessfully:

    UPDATE `_files` SET `img_path` = "./Photos/" + `img_name`;

    which means: I want to fill in table _files all the rows of the column img_path with the string "./Photos/" plus the whole content of the corresponding row in column img_name

    Example: if a row in column img_name contains "blah blah.jpg", I want the corresponding row in column img_path to contain "./Photos/blah blah.jpg" (even if "blah blah.jpg" contains a space!)

    The above query set all rows in img_path to 0 (zero not o) except some which contains a part of the content of img_name...

    img_path and img_name are varchar(100), utf8_general_ci, no Attributes, NULL=No, no Extra

    Many thanks in advance for your help!
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    there is no "+" concatenation operator in MySQL. You need to use CONCAT.

    Apart from that, saving the same directory for every image is obviously redundant and makes no sense. It can lead to conflicting data, and you have to change every single row whenever you change the file path.

    Instead, put the directory name into a separate "file_paths" or "configuration" table. Or simply hard code it in your application.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2004
    Location
    Pierrefonds, QC Canada
    Posts
    205
    Rep Power
    11
    Thanks for your reply!

    Silly of me! Of course, the "+" sign has nothng to do here!
    I thought I still was in Action Scripting in Flash...

    Regards,

    Gerard
    Last edited by Germaris; January 12th, 2013 at 06:12 PM.

IMN logo majestic logo threadwatch logo seochat tools logo