mysql ÔõÑù²ÅÄܶÔͬһÕűí²éѯºóÔÙ¸üÐÂ?
Çë¸ßÊÖÖ¸µã,ÎÒ¶ÔÒ»Õűí²éѯºóÔÙ¸üÐÂ,²éѯÊÇ×Ó²éѯ,±¨´í:
You can't specify target table 'a_table' for update in from clause
ÍêÕûSQLÓï¾äÊÇ
UPDATE a_table SET STATUS=0 WHERE ID=(SELECT MIN(ID) from a_table WHERE STATUS=1 AND SID=12321);
ÕâÊÇMYSQL¾ö¶¨Á˶ԴËд·¨²»¼æÈÝÂð?ÓÐʲô·½·¨¿ÉÒÔ²»Óòð·ÖÈËÁ½Ìõ?
mysql²»ÔÊÐí¸üлòÕßɾ³ýÒ»¸ö±íÖÐÊý¾ÝµÄͬʱ´Óͬһ¸ö±íÖвéѯ£¬ÓÃÁ¬½Ó²éѯ¡£
SQL code:
UPDATE a_table a INNER JOIN
(SELECT MIN(id) mid
from a_table WHERE status=1 AND sid=12321) b
ON a.id=b.mid
SET a.status=0
UPDATE a_table A ,(SELECT MIN(ID) AS MI from a_table WHERE STATUS=1 AND SID=12321) B
SET A.STATUS=0
WHERE A.ID=B.MI;
Ïà¹ØÎÊ´ð£º
Ò»¸öÐÐÒµÍøÕ¾£¬ÒªÊµÏֵŦÄÜÒªÇóΪ£º
Ò»ËÑË÷±íµ¥¿ÉÑ¡ËÑË÷ ²úÆ·/×ÊѶ/É̼ң¬ËÑË÷ʱϣÍûÏÈËѱêÌâºóÈ«ÎÄ£¬µ±Ç°µÄÊý¾ÝÁ¿¹À¼Æ3Íò¶à£¬¶¨Î»ÆÚÍûÔÚ°ÙÍò¼¶Ò²¿ÉÓá£
Êý¾ÝÀàÐÍΪinnodb£¬µ±Ç°µÄ·½·¨ÊǶԹؼü´Ê½øÐÐ ......
ÎÒÒÔÇ°°²×°ÁËÒ»´Î£¬ºóÀ´Ð¶ÔØÁË£¬ÏÖÔÚÔÙ°²×°µÄʱºò£¬Ìáʾ´íÎó£ºError 1305.Error reading from file C:DOCUME~1\LOCALS~1\Temp\mysql_server.msi.Verify that the file exists and that you can access it.
¿ÉÊÇÎÒÕÒ ......
ÔÚÈýÊ®½²Óöµ½ÕâÑùÒ»¸öÎÊÌâ¾ÍÊÇÔËÐдúÂëʱ³öÏÖ´íÎó Fatal error: Call to undefined method mysql::fetch_array() in D:\WWW\news\index.php on line 12
£¬ÎÒ°Ñmysql::fetch_array() ¸Ä³Émysql::fetch_row() ÓÖ³öÏÖF ......
Õâ¸öÊÓƵ½²µÄºÜÏêϸ, ¶ÔÐÂÊַdz£ÓÐÓÃ, »ù±¾ÉÏÒ»¿´¾Í¶®
ÓÉÓÚÌ«´óÁË(50m, ÎÒÖ»ÄÜÉÏ´«20m), ÎÒÉÏ´«²»ÁË, Ö»ºÃÌù³öÏÂÔصØÖ·
ÏÂÔصØÖ·: http://ftel1.3800hk.com/0807/080720djxnzj.rar
ºÃ¶«Î÷,ϸö¿´¿´
......
ÇëÎÊÏÂÄܲ»ÄÜÔÙwindows϶¨ÆÚÇå¿ÕmysqlÒ»¸ö±íÖеÄÈ«²¿Êý¾Ý£¬ÓÃPHPʵÏÖ£¡
лл¸÷λÁË
¾Í±ÈÈçÒ»¸öÐÇÆÚÇå¿ÕÒ»´Î
±ÈÈçÿ¸öÐÇÆÚÁùÁãµãÇå¿ÕÒ»´Î£¡
ллÁË
¼Æ»®ÈÎÎñ...php....sql...truncate....OK
Äã¾ÍÕâ½ÓÔÚҳà ......