25 users online (0 members and 25 guests)  

Thread: 2 questions


  Results 1 to 2 of 2

Related

  1. some php questions    Forum: PHP Forum
    Replies: 0
  2. 3 questions    Forum: CGI Perl Forum
    Replies: 2
  3. How to do this in CSS? A few questions.    Forum: CSS Forum
    Replies: 0
  4. Six Questions    Forum: HTML Forum
    Replies: 4
  5. Questions...    Forum: HTML Forum
    Replies: 1
  1. #1
    Jasongr's Avatar
    New User

    Status
    Offline
    Join Date
    May 2005
    Posts
    4

    2 questions

    Hi people

    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:
    Code:
        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;
    Table item is populated with information on files. Table image is populate with data except that the value in column 'Extension' is empty.
    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.

    Something like:
    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
    Jason

  2. #2
    Jasongr's Avatar
    New User

    Status
    Offline
    Join Date
    May 2005
    Posts
    4

    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;

    Jason



Tags for this Thread