mysql ¼òµ¥ÎÊÌâ
¼ÙÈçÊý¾Ý¿âÖÐÓиötest±í£¬±íÖÐÓÐid£¬Name£¬num£¬¼Ç¼ʱ¼ä
idΪ×ÔÔö³¤Ö÷¼ü£¬nameÊÇÃû×Ö£¬num±íʾÆäÊýÁ¿
1 nike 100 ϵͳʱ¼ä
2 nike 300 ϵͳʱ¼ä
3 nike 2000 ϵͳʱ¼ä
ÏÖÔÚÎÒÏëʵÏÖ´ÓÊý¾Ý¿âÖмìË÷³önameΪnikeµÄ¼Ç¼£¬¼õÈ¥500£¬½á¹ûΪ
1 nike 0 ϵͳʱ¼ä
2 nike 0 ϵͳʱ¼ä
3 nike 1900 ϵͳʱ¼ä
ÔÚÊý¾Ý¿â¶Î¸ÃÈçºÎʵÏÖ£¿
SQL code:
select
id,
name,
IF(
((select sum(num) from test where name='nike' and rtime<=t.rtime)-500)<0,
0,
(select sum(num) from test where name='nike' and rtime<=t.rtime)-500
)
rtime
from
test t
where
name='nike'
SQL code:
--2Â¥Õý½â£¬Ã»»°Ëµ£¬Ò»¸ö×Ö£º¶¥£¡
SQL code:
mysql> select * from test;
+------+------+------+---------------------+
| id | name |
Ïà¹ØÎÊ´ð£º
ÎÒÊÇÓÃmysql×Ô´øµÄC API
if(mysql_real_connect(&mysql,"125.0.0.108","root","root","home",3306,NULL,0))
{
AfxMessageBox("Êý¾Ý¿âÁ¬½Óʧ°Ü") ......
ÎÒÒÔÇ°°²×°ÁËÒ»´Î£¬ºóÀ´Ð¶ÔØÁË£¬ÏÖÔÚÔÙ°²×°µÄʱºò£¬Ìáʾ´íÎó£º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.
¿ ......
ÇëÎÊÈçºÎ¸øMySQLÊý¾Ý¿â´«µÝDATETIMEÊý¾Ý£¿ÎÒÓõÄdate("Y-N-d H:i:s",time())²»ÐС£
SQL code:
mysql> desc t;
+-------+----------+------+-----+---------+-------+
| Field | Type | Null ......
mysql£º
·þÎñÆ÷: Localhost via UNIX socket
·þÎñÆ÷°æ±¾: 5.1.33-log
ÐÒé°æ±¾: 10
Óû§: root@localhost
MySQL ×Ö·û¼¯: UTF-8 Unicode (utf8)
´íÎó£º
SQL ²éѯ:
CREATE TABLE ......