SQL experts, can you please help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Just Alex
    Liv Benson to You, Bitch
    • Aug 2007
    • 6060

    #1

    SQL experts, can you please help.

    Ok, so I have primary key thats AUTO_INCREMENT. There's another field file_name that I need to populate with number from primary key plus file extension

    So right now its like this and I need to run an update query to populate file_name fields

    File_Id File_name
    1 NULL
    2 NULL
    3 NULL


    To be


    File_Id File_name
    1 1.jpg
    2 2.jpg
    3 3.jpg

    What's correct structure of update query?

    Thank you

  • Brujah
    Beer Money Baron
    • Jan 2001
    • 22157

    #2
    UPDATE table SET File_name = CONCAT( File_id, '.jpg' );

    Comment

    • Just Alex
      Liv Benson to You, Bitch
      • Aug 2007
      • 6060

      #3
      Originally posted by Brujah
      UPDATE table SET File_name = CONCAT( File_id, '.jpg' );
      Huh, it worked. Im so stupid adding convert(varchar(100) to this thinking numeric field cant be concatenated in text fields.

      Thank you very much!

      Comment

      Working...