473,406 Members | 2,336 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,406 software developers and data experts.

Error while using MAX function in update clause

33
Hi
i want to update the recorde like this
Expand|Select|Wrap|Line Numbers
  1. UPDATE category_shops SET category_shops_id = (SELECT MAX(`category_shops_id`)+1 FROM category_shops) WHERE category_shops_id = 0 AND shop_id= 14856 AND category_id = 14
  2.  
but getting the error
"1093 - You can't specify target table 'category_shops' for update in FROM clause "

please help me
Jan 2 '08 #1
3 2462
rpnew
188 100+
Hi
i want to update the recorde like this
Expand|Select|Wrap|Line Numbers
  1. UPDATE category_shops SET category_shops_id = (SELECT MAX(`category_shops_id`)+1 FROM category_shops) WHERE category_shops_id = 0 AND shop_id= 14856 AND category_id = 14
  2.  
but getting the error
"1093 - You can't specify target table 'category_shops' for update in FROM clause "

please help me

Its because you are Updating the table which you are using in the select clause. Which is not allowed or cant be done...
Check the following link for MySql 5.0 manual...

Update Query for Mysql

and read the last line before user comments.....

same is true for MySql 5.1 and 6.0 also. check their respective manual as well.. for update queries....
So what you can do here is use "select" clause first assign its value to some variable and then use it in "update" query... try this if it works..

Regards,
RP
Jan 3 '08 #2
mwasif
802 Expert 512MB
Hi RuthC,

Kindly use appropriate CODE tags when posting code.Checkout the Supported CODE tags.
Jan 3 '08 #3
RuthC
33
Thanks Its Working

Expand|Select|Wrap|Line Numbers
  1.  
  2.     $text = "Test Text";
  3.     $image = imagecreatetruecolor(200,45);
  4.     $white = imagecolorallocate($image,255,255,255);
  5.     imagefill($image,0,0,$white);
  6.     $red = imagecolorallocate($image,255,0,0);
  7.     $degrees = (173/strlen($text)/3.7);
  8.     for ($i=0;$i<strlen($text);$i++) {
  9.         $a = ($degrees*$i)+246;
  10.         $cos = cos(deg2rad($a));
  11.         $sin = sin(deg2rad($a));
  12.         $x = 180;
  13.         $y = 0;
  14.         $xt = round($cos*($x) - $sin*($y));
  15.         $yt = round($sin*($x) + $cos*($y));
  16.         imagettftext($image,12,280-($a),80+$xt,200+$yt,$red,"C:/WINDOWS/Fonts/verdana.TTF",$text[$i]);
  17.     }
  18.     header("Content-type: image/jpeg");
  19.     imagejpeg($image,"",100);
  20.     imagedestroy($image);
  21.  
  22.  
Jun 5 '08 #4

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

Similar topics

4
by: Bob Stearns | last post by:
The statement: merge into nullid.animals_et_in t1 using is3.animals t2 on t1.sire_assoc=t2.assoc and t1.sire_prefix=t2.prefix and t1.sire_regnum=t2.regnum when matched then update set...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: Jerry | last post by:
Well, here is some weirdness. First, I noticed that I have 2 Set keywords (silly me). so I removed the 2nd "Set" but still got a syntax error. Then I removed the Where clause, and now it works...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
by: Szymon Dembek | last post by:
Hi Recently I did some DB2 and ODBC coding in Visual FoxPro. I bumped on a problem I cannot resolve. When I issue a delete statement that deletes no rows (no rows qualify for the WHERE...
0
by: mbenedict | last post by:
I am rather new at this code and am attempting to modify existing code to use clob datatypes, which I have never used before. The database tables have been set up for clob data. When trying to use...
3
by: bilbo | last post by:
Can anybody help me understand why I get the error "Syntax error in CONSTRAINT clause"? I get it in Access 2003 and Access 2007. Both are clean installs with no add-ins Running this code in...
10
by: Chris H | last post by:
Greetings, I'm trying to update an address field with "standard" abbreviations so that I can do a comparison of various accounts to one another on the address. I can update a set of records for...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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 projectplanning, 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.