GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   SQL experts, can you please help. (https://gfy.com/showthread.php?t=1069118)

Just Alex 05-23-2012 01:46 PM

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

http://i.backpackgnome.com/174092006...0.65184957.gif

Brujah 05-23-2012 02:10 PM

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

Just Alex 05-23-2012 02:13 PM

Quote:

Originally Posted by Brujah (Post 18961853)
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!


All times are GMT -7. The time now is 11:35 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123