473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

I have some problem when i update mysql table

Expand|Select|Wrap|Line Numbers
  1. UPDATE collection SET image_name = 'collection_diir/1225542431.jpg',
  2. Code = 'qqq',
  3. Media = 'qqq',
  4. Dimensions = 'qqq',
  5. Availbility = 'qqq' WHERE
  6.  collection. image_id = '7'  AND collection. image_name = `collection_dir/19521.jpg`

such SQL query is not work


Table Structure is as follow


Table structure for table `collection`
--
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `collection` (
  2.   `artist_id` int(11) NOT NULL,
  3.   `image_id` int(11) NOT NULL auto_increment,
  4.   `image_name` varchar(100) NOT NULL,
  5.   `image_thumbs` varchar(100) NOT NULL,
  6.   `Code` varchar(100) NOT NULL,
  7.   `Media` varchar(100) NOT NULL,
  8.   `Dimensions` varchar(100) NOT NULL,
  9.   `Availbility` varchar(100) NOT NULL,
  10.   PRIMARY KEY  (`image_id`)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;
  12.  
  13. -- 
  14. -- Dumping data for table `collection`
  15. -- 
  16.  
  17. INSERT INTO `collection` (`artist_id`, `image_id`, `image_name`, `image_thumbs`, `Code`, `Media`, `Dimensions`, `Availbility`) VALUES 
  18. (5, 5, 'collection_dir/24528.jpg', 'collection_dir/thumbs/thumbs_1224932899.gif', '', '', '', ''),
  19. (5, 6, 'collection_dir/24528.jpg', 'collection_dir/thumbs/thumbs_1224932971.gif', '', '', '', ''),
  20. (5, 7, 'collection_diir/1225542431.jpg', 'collection_dir/thumbs/thumbs_1224933091.jpg', 'qqq', 'qqq', 'qqq', 'qqq'),
  21. (5, 8, 'collection_dir/24528.jpg', 'collection_dir/thumbs/thumbs_1224933097.jpg', '', '', '', ''),
  22. (6, 9, 'collection_dir/1225533128.jpg', 'collection_dir/thumbs/thumbs_1225533128.jpg', '', '', '', ''),
  23. (6, 10, 'collection_dir/1225533133.jpg', 'collection_dir/thumbs/thumbs_1225533133.jpg', '', '', '', ''),
  24. (6, 11, 'collection_dir/1225533138.jpg', 'collection_dir/thumbs/thumbs_1225533138.jpg', '', '', '', ''),
  25. (7, 12, 'collection_dir/1225542399.jpg', 'collection_dir/thumbs/thumbs_1225542399.jpg', '', '', '', ''),
  26. (7, 13, 'collection_dir/1225542406.jpg1', 'collection_dir/thumbs/thumbs_1225542406.jpg', '', '', '', ''),
  27. (7, 14, 'collection_dir/19521.jpg', 'collection_dir/thumbs/thumbs_12255424114.jpg', 'aaa', 'aaa', 'aaa', 'aaaa'),
  28. (7, 15, 'collection_dir/1225542421.jpg', 'collection_dir/thumbs/thumbs_1225542421.jpg', '', '', '', ''),
  29. (7, 16, 'collection_dir/1225542431.jpg', 'collection_dir/thumbs/thumbs_1225542431.jpg', '', '', '', '');
  30.  
Plz say me right solusiion
Nov 1 '08 #1
2 1307
This is pretty simple, replace ( ` ) with ( ' ) in your sql like this

Expand|Select|Wrap|Line Numbers
  1. UPDATE collection SET image_name = 'collection_diir/1225542431.jpg',
  2. Code = 'qqq',
  3. Media = 'qqq',
  4. Dimensions = 'qqq',
  5. Availbility = 'qqq' 
  6. WHERE
  7. collection.image_id = '7' AND collection.image_name = 'collection_dir/19521.jpg'
Nov 1 '08 #2
Atli
5,058 Expert 4TB
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;
Expand|Select|Wrap|Line Numbers
  1. /* It should be */
  2. UPDATE whatever WHERE image_id = 1;
  3. /* NOT */
  4. UPDATE whatever WHERE image_id = '1';
  5.  
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
Nov 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Westcoast Sheri | last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database (2 columns: "fruit" and "quantity")....so can we make these following mySQL queries work somehow? (visitor buys 5...
2
by: Simon | last post by:
Hi, We have a small utility that uses a database. We are happy with the structure of the database but we cannot predict any updates. What we are particularly concerned about are updates vs....
0
by: Jeremiah Jacks | last post by:
I just upgraded to MySQL 4.0.14-standard for RedHat Linux and am using = the pre-compiled binaries. I have a database with INNODB tables. When I insert a row into one of the child tables, I get...
0
by: Dan Jones | last post by:
How do I update a table to remove orphaned references to a second table? I've deleted rows in the second table, which has a unique auto_increment key. The first table now has references to keys...
3
by: Michael Lauzon | last post by:
This is not for a class, I have a group on SourceForge, this is what one of the Developers is asking; the more advanced you can make it right off all the better!: Can someone please create...
1
by: John | last post by:
I wanna update the table COMPANY from a linked field. The following is not accepted. Could anybody help me with what the command should be? Thanks a lot. UPDATE `COMPANY` SET...
3
by: fuimens | last post by:
Hi, With mysql-4.0.20, I have a problem inserting data with foreign key references, MySQL saying ERROR 1216: Cannot add or update a child row: a foreign key constraint fails The message is...
4
by: UKuser | last post by:
Hi Guys, I am trying to create an editable table of a MySQL query where every field can be updated. My example script is at: http://nana46.coconia.net/test4.php however I am currently getting...
7
by: Jon Maz | last post by:
Hi, I have a MySql problem I hope someone can help me with. I'm trying to run an update on a linking table, the update is running into a Primary Key constraint violation, and in my workaround...
0
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.