I have some problem when i update mysql table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manoj10029
    New Member
    • Oct 2008
    • 1

    #1

    I have some problem when i update mysql table

    [code=sql]UPDATE collection SET image_name = 'collection_dii r/1225542431.jpg' ,
    Code = 'qqq',
    Media = 'qqq',
    Dimensions = 'qqq',
    Availbility = 'qqq' WHERE
    collection. image_id = '7' AND collection. image_name = `collection_dir/19521.jpg`[/code]


    such SQL query is not work


    Table Structure is as follow


    Table structure for table `collection`
    --
    [code=sql]
    CREATE TABLE `collection` (
    `artist_id` int(11) NOT NULL,
    `image_id` int(11) NOT NULL auto_increment,
    `image_name` varchar(100) NOT NULL,
    `image_thumbs` varchar(100) NOT NULL,
    `Code` varchar(100) NOT NULL,
    `Media` varchar(100) NOT NULL,
    `Dimensions` varchar(100) NOT NULL,
    `Availbility` varchar(100) NOT NULL,
    PRIMARY KEY (`image_id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT= 17 ;

    --
    -- Dumping data for table `collection`
    --

    INSERT INTO `collection` (`artist_id`, `image_id`, `image_name`, `image_thumbs`, `Code`, `Media`, `Dimensions`, `Availbility`) VALUES
    (5, 5, 'collection_dir/24528.jpg', 'collection_dir/thumbs/thumbs_12249328 99.gif', '', '', '', ''),
    (5, 6, 'collection_dir/24528.jpg', 'collection_dir/thumbs/thumbs_12249329 71.gif', '', '', '', ''),
    (5, 7, 'collection_dii r/1225542431.jpg' , 'collection_dir/thumbs/thumbs_12249330 91.jpg', 'qqq', 'qqq', 'qqq', 'qqq'),
    (5, 8, 'collection_dir/24528.jpg', 'collection_dir/thumbs/thumbs_12249330 97.jpg', '', '', '', ''),
    (6, 9, 'collection_dir/1225533128.jpg' , 'collection_dir/thumbs/thumbs_12255331 28.jpg', '', '', '', ''),
    (6, 10, 'collection_dir/1225533133.jpg' , 'collection_dir/thumbs/thumbs_12255331 33.jpg', '', '', '', ''),
    (6, 11, 'collection_dir/1225533138.jpg' , 'collection_dir/thumbs/thumbs_12255331 38.jpg', '', '', '', ''),
    (7, 12, 'collection_dir/1225542399.jpg' , 'collection_dir/thumbs/thumbs_12255423 99.jpg', '', '', '', ''),
    (7, 13, 'collection_dir/1225542406.jpg1 ', 'collection_dir/thumbs/thumbs_12255424 06.jpg', '', '', '', ''),
    (7, 14, 'collection_dir/19521.jpg', 'collection_dir/thumbs/thumbs_12255424 114.jpg', 'aaa', 'aaa', 'aaa', 'aaaa'),
    (7, 15, 'collection_dir/1225542421.jpg' , 'collection_dir/thumbs/thumbs_12255424 21.jpg', '', '', '', ''),
    (7, 16, 'collection_dir/1225542431.jpg' , 'collection_dir/thumbs/thumbs_12255424 31.jpg', '', '', '', '');
    [/code]

    Plz say me right solusiion
    Last edited by Atli; Nov 1 '08, 03:32 PM. Reason: Added [code] tags.
  • samatair
    New Member
    • Nov 2007
    • 61

    #2
    This is pretty simple, replace ( ` ) with ( ' ) in your sql like this

    [CODE=sql]UPDATE collection SET image_name = 'collection_dii r/1225542431.jpg' ,
    Code = 'qqq',
    Media = 'qqq',
    Dimensions = 'qqq',
    Availbility = 'qqq'
    WHERE
    collection.imag e_id = '7' AND collection.imag e_name = 'collection_dir/19521.jpg'[/CODE]
    Last edited by Atli; Nov 1 '08, 03:33 PM. Reason: Added [code] tags.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      Your image_id is an integer, and as such, it's value should not be quoted. Only string values should be quoted.

      That is;
      [code=mysql]
      /* It should be */
      UPDATE whatever WHERE image_id = 1;
      /* NOT */
      UPDATE whatever WHERE image_id = '1';
      [/code]

      And both of you:
      Please use [code] tags when posting your code examples. (See How to ask a question)

      [code] ... Code goes here... [/code]

      Thank you.
      Moderator

      Comment

      Working...