dflow Posted September 21, 2011 Share Posted September 21, 2011 how can i perform this directly in phpmyadmin : UPDATE `apartments` SET mainImage = ID-SupplierID-0.jpg WHERE InternalSupplierID=7'; ID SupplierID are table fields in apartments it's actually a foreach loop Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted September 21, 2011 Share Posted September 21, 2011 what's the problem when you try that in PHPMyAdmin? Quote Link to comment Share on other sites More sharing options...
dflow Posted September 21, 2011 Author Share Posted September 21, 2011 what's the problem when you try that in PHPMyAdmin? #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'jpg WHERE InternalSupplierID=7' at line 1 Quote Link to comment Share on other sites More sharing options...
awjudd Posted September 21, 2011 Share Posted September 21, 2011 You are missing the quotes around your string ... and you have 1 too many quotes at the end ... UPDATE `apartments` SET mainImage = CONCAT(CAST(ID-SupplierID-0 AS VARCHAR(50)),'.jpg') WHERE InternalSupplierID=7; Quote Link to comment Share on other sites More sharing options...
dflow Posted September 21, 2011 Author Share Posted September 21, 2011 You are missing the quotes around your string ... and you have 1 too many quotes at the end ... UPDATE `apartments` SET mainImage = CONCAT(CAST(ID-SupplierID-0 AS VARCHAR(50)),'.jpg') WHERE InternalSupplierID=7; still quote error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VARCHAR(50)),'.jpg') WHERE InternalSupplierID=7' at line 1 Quote Link to comment Share on other sites More sharing options...
awjudd Posted September 21, 2011 Share Posted September 21, 2011 But it is now at a different spot ... Looking at the definition for CONCAT (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat) you can give it a number. UPDATE `apartments` SET mainImage = CONCAT(ID-SupplierID-0,'.jpg') WHERE InternalSupplierID=7; Quote Link to comment Share on other sites More sharing options...
dflow Posted September 21, 2011 Author Share Posted September 21, 2011 But it is now at a different spot ... Looking at the definition for CONCAT (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat) you can give it a number. UPDATE `apartments` SET mainImage = CONCAT(ID-SupplierID-0,'.jpg') WHERE InternalSupplierID=7; this updated, but only ID.jpg without -0 output: 34567.jpg instead of 34567-12-0.jpg thanks ill read about CONCAT Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted September 21, 2011 Share Posted September 21, 2011 so what you're looking for is this ?: UPDATE `apartments` SET mainImage = CONCAT(ID, '-', SupplierID, '-', 0 ,'.jpg') WHERE InternalSupplierID=7; Quote Link to comment Share on other sites More sharing options...
dflow Posted September 21, 2011 Author Share Posted September 21, 2011 so what you're looking for is this ?: UPDATE `apartments` SET mainImage = CONCAT(ID, '-', SupplierID, '-', 0 ,'.jpg') WHERE InternalSupplierID=7; cheers! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.