Thread: 2 questions
Results 1 to 2 of 2
05-09-2006, 02:13 AM #1
I have 2 questions on how to format queries:
1) I have a table with a given column of type varchar(255)
All the records in the table have some value for that column
I would to modify the values in that column in ALL the records
for that table by appending the value '_test' at the end
How can I do this?
Assume that the table name is: 'tbl' and the column name is 'clmn'
I need something like append function
2) I have 2 tables:
CREATE TABLE `item` ( `Item_ID` int unsigned not null auto_increment, `GUID` varchar(255) not null, `Extension` varchar(255) not null, PRIMARY KEY (`Item_ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE `image` ( `Image_ID` int unsigned not null auto_increment, `GUID` varchar(255) not null, `Extension` varchar(255) not null, PRIMARY KEY (`Image_ID`), ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Columns GUID are used to perform joins between these 2 tables
I need to update table image by setting the value of the column 'Extension' in that table from the column 'Extension' in table file.
update image set image.Extension = file.extension where image.GUID = file.GUID;
This doesn't work because I get the following error:
Unknown column 'file.GUID' in 'where clause'
My syntax is obviously wrong
any help would be appreciated
05-09-2006, 02:39 AM #2
Re: 2 questions
Here are the solutions that I found:
1) update tbl set clmn = CONCAT(clmn, '_test');
2) update image, file set image.Extension = file.Extension WHERE image.GUID = file.GUID;