mysql updateÓï¾äµÄÎÊÌâ
ÎÒÏëÒª¸üÐÂij¸ö±íÅÅÐòºó¿¿Ç°µÄÊý¾Ý£¬ÓÚÊÇдÁËÒ»¸öÓï·¨£º
update dcproduct set pOrder=pOrder+2 order by pOrder desc,id desc limit 6£»Õâ¸öÊÇ¿ÉÒÔÔËÐеģ¬½á¹ûÊǸüÐÂÁËÇ°ÁùÌõ¼Ç¼¡£
ºóÀ´·¢ÏÖ©Á˸öÌõ¼þÒªÁ¬±í²éѯÓÚÊÇд³É£º
update dcproduct a join dcproductsort b on a.pSortid=b.id set pOrder=pOrder+2 where parentid=1 order by a.pOrder desc,id desc limit 6;
½á¹û¾Í±¨´íÁË£¬
ÓÐûÓÐÈËÖªµÀÔõôд°¡£¿
±¨´íÐÅÏ¢ÊÇʲô£¿ ûÓбØÒªÈôó¼Ò²Â°É¡£
#1221 - Incorrect usage of UPDATE and ORDER BY
UPDATEÖÐÈç¹ûÊÇÁ½¸ö±í£¬Ôò²»ÄÜʹÓà order / limit
²»ºÃÒâ˼,ÎÒÏëÒª½â¾ö°ì·¨£¬²»ÊÇ´íÎóÔÒò....
²»ºÃÒâ˼,ÎÒÏëÒª½â¾ö°ì·¨£¬²»ÊÇ´íÎóÔÒò....
try:
update dcproductsort b join
(select * from dcproduct
order by pOrder desc,id desc limit 6) a
on a.pSortid=b.id set pOrder=pOrder+2 where parentid=1
½¨Òé¸ø³öÄãµÄ²âÊÔÊý¾Ý£¬ÕâÑù±È½ÏÈÝÒ×Á˽âÄãµÄÐèÒªÊÇʲô¡£
½¨ÒéÄãÁгöÄãµÄ±í½á¹¹£¬²¢Ìṩ²âÊÔÊý¾ÝÒÔ¼°»ùÓÚÕâЩ²âÊÔÊý¾ÝµÄËù¶ÔÓ¦ÕýÈ·½á¹û¡£
6Â¥µÄ´ó´ó£¬±¨´í
#1288 - The target table a of the UPDATE is not updatable
ÎÒµÄÊý¾ÝºÜ¼òµ¥£¬product±íÊDzúÆ·£¬productsortÊÇ·ÖÀ࣬pOrderÊDzúÆ·µÄÅÅÐò×ֶΣ¬Ç°Ì¨ÅÅÐò°´ÕÕ ÅÅÐò×ֶκÍid×Ö¶ÎÅÅ£¬
Ä¿Ç°Òª×öµÄ¾ÍÊÇ°Ñǰ̨ÏÔʾÔÚ×îÇ°ÃæµÄ¼¸ÌõÊý¾ÝµÄpOrderÔö¼Ó2¡£
ÏÈлл´ó¼Ò°ïÖúÀ£¬Èç¹û²»ÐÐÎÒÖ»ÄÜͨ¹ýÆäËû³ÌÐòʵÏÖÁË¡£
ÔÚMYSQL¡¡5¡£.1¡£32ϲâÊÔ£¬SQLÓï¾äûÓÐÎÊÌâ
UPDATE lsb3 b JOIN
(SELECT * from lsb2
Ïà¹ØÎÊ´ð£º
Ò»¸öÐÐÒµÍøÕ¾£¬ÒªÊµÏֵŦÄÜÒªÇóΪ£º
Ò»ËÑË÷±íµ¥¿ÉÑ¡ËÑË÷ ²úÆ·/×ÊѶ/É̼ң¬ËÑË÷ʱϣÍûÏÈËѱêÌâºóÈ«ÎÄ£¬µ±Ç°µÄÊý¾ÝÁ¿¹À¼Æ3Íò¶à£¬¶¨Î»ÆÚÍûÔÚ°ÙÍò¼¶Ò²¿ÉÓá£
Êý¾ÝÀàÐÍΪinnodb£¬µ±Ç°µÄ·½·¨ÊǶԹؼü´Ê½øÐÐ ......
ÎÒÔÚ×¢²áÒ³ÃæдÈëÁËÈçÏ´úÂ룺
<?php
$conn=mysql_connect("localhost","root","614510")or die("Êý¾Ý¿â·þÎñÆ÷Á¬½Ó´íÎó".mysql_error());
& ......
MySQLÈëÃÅ
¿ÉÒÔÏÈ¿´Ê²Ã´Êé¼®°¡£¿
ÏȶÁÈý±é¡¶Êý¾Ý¿âϵͳ¸ÅÂÛ¡·,ÕÆÎÕÊý¾Ý¿âµÄ»ù´¡ÀíÂÛ¡£
È»ºóÔÙ´Ö¿´Ò»±éMYSQLµÄ¹Ù·½Îĵµ¡£ MySQL¹Ù·½Îĵµ http://dev.mysql.com/doc/refman/5.1/zh/index.html
¾ÍÕÒÒ»±¾ºÜ»ù´ ......
SELECT a.tguildname ,SUM(a.ct) + if (SUM(b.ct) IS NULL ,0,SUM(b.ct)) from (
SELECT tg.tguildname,c.cid, (
cf.fbb + cf.fgjbb + cf.fjybb + cf.fqb + cf.fgjqb + cf.fjyqb + cf.fqib + cf. ......
ÇëÎʸ÷λ´ó¸ç£¬¾²Ì¬±àÒëʱ£¬mysql±àÒëÑ¡Ïî--with-mysqld-ldflagsºóÃæÓÃ-all-staticºÍ-staticÓÐʲô²»Í¬Âð£¿
ÒýÓÃ
-all-static ¼ûµ½¹ý£¬ÊÇËùÓеÄÎļþΪ¾²Ì¬LINK£¬ÕâÑùmysqldµÄÔËÐÐЧÂÊ»á±È½Ï¸ß£¬Í¬Ñù³ß´ç»á ......