ÇóÒ»sqlÓï¾ä - PHP / »ù´¡±à³Ì
±íµÄ½á¹¹
articleid, userid, date
1,1 ,12234234234
2,1 ,23423423423
3,2 ,22222222222
4,3 ,22222222111
5,3 ,23423423423
key articlied
Ò»¸öÎÄÕµıí½á¹¹¡£
ÈçºÎÇóµÃÒ»¸öÓû§µÄµÚÒ»¸ö×÷Æ·£¬
¿ÉÒԵĻ°ÔÙ¼ÓÒ»¸öÐèÇó£¬Ò»¸öÔÂÄÚµÄ
$time = mktime(0, 0, 0, -1);
$sql = "select * from xxx where userid = 1 and date > {$time} order by articleid ASC limit 1";
select * from xxx where userid = 1 limit 1
"select * from table where userid = '$userid' order by date ASC limit 1"
ÎÒ¾õµÃÕâÑù¿ÉÒÔËÑË÷µ½Ä³È˵ĵÚÒ»¸ö×÷Æ·ÁË°¡
µ¥¸öÓû§µÄÈ·ÊÇÕâÑù×îºÃ,
µ«Í¬Ê±È¡ËùÓÐÓû§µÄ²úÆ·,¾Í²»ÐÐÁË.
²»ÖªµÀÕâÑùÊÇ·ñ¿ÉÒÔ£¬ÎÒ¶ÔÁ˼¸¸öÊý¾Ý¡£
select articleid,userid, date from (select * from t1 order by date asc) article group by userid limit 10;
¼ÓÉÏʱ¼äÊÇÕâÑùµÄ£º
select articleid,userid, date from (select * from t1 order by date asc) article group by userid having date>(unix_timestamp()-3600*24*31) limit 10;
Æäʵ»¹ÓÐÐèÇ󣬻¹Òª¸ù¾ÝÊÕ²ØÊý¡£µ«Èç¹ûÉϱßÕýÈ·µÄ»°£¬ÉϱߵÄÎÒ¿ÉÄÜ»áÉú³ÉÒ»¸öÁÙʱ±í¡£
¶þÂ¥µÄ¸Ð¾õ¿ÉÒÔ
¶÷£¡¶þÂ¥¿ÉÐУ¡ÎÒ»áÏÈÉú³ÉÒ»¸öÁÙʱ±í£¡»á²ÉÓöþÂ¥µÄд·¨
select min(articleid) from t1 group by userid£¬
ÓÃÕâ¸öÓï¾äÏȲé³öarticleid£¬È»ºóÔÙ²éÏêϸÐÅÏ¢¡£Ð´ÈëÁÙʱ±í¡£
ÕâÑù¶ÔÊý¾ÝÁ¿´óµÄÒ²¿ÉÐС£Ð»Ð»ÁË£¡´óÏÀ£¡
ѧϰÁË¡£¡£¡£
PHP code
Code highlighting produced by Actipro CodeHighlighter (fre
Ïà¹ØÎÊ´ð£º
tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£©
tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname
½á¹û£º
µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......
ÏÖÓÐÒ»PHP¿Õ¼ä£¬Ö§³ÖMYSQLÊý¾Ý¿â
Ϊ½ÚÊ¡·ÑÓã¬ÏÖÏëͨ¹ýÓòÃûתÏòĿ¼ÐÎʽ½øÐйÜÀí£¨¼´½«ÓòÃûA¼Ç¼£Û°üÀ¨¶¥¼¶ÓòÃû¼°¶þ¼¶ÓòÃû£Ý¶¼Ö¸Ïòͬһ¿Õ¼ä£©
È磺·ÃÎÊÓòÃû abcd.cn Ö±½Ó·ÃÎÊÍøÕ¾¸ùĿ¼
·ÃÎʶþ¼¶ÓòÃû ef.abcd.cn ......
ÐèÇóÈçÏ£º
ѧԺ academy£¨aid,aname£©
°à¼¶ class£¨cid,cname,aid£©
ѧÉú stu(sid,sname,aid,cid)
סËÞÇø region(rid,rname)
ËÞÉáÂ¥ build(bid,rid,bnote) bnoteÊÇ¡®ÄС¯/¡®Å®¡¯
ËÞÉá dorm(did,rid,bid£¬bedn ......
±íÊý¾Ý
COL1 COL2 COL2 COL4 COL5
----------------------------------------------------------------------------------------------
2010-05-05 00:00 ......
¸÷λºÃ£¬ÎÒ¸Õ°ÑÒ»¸öASPÍøÕ¾ÉèÖúÃÁË£¬Ò²ÄÜÕý³£·ÃÎÊ¡£µ«ÊÇÔÚÎÒ±¾»úÉϲ»ÄÜ´ò¿ªadmin\login.asp,ËùÒÔÎÞ·¨ÊµÏÖºǫ́¹ÜÀí¡££¨´íÎóÌáʾÎÞ·¨ÕÒµ½ÍøÒ³£¬´úÂë404£¬ÎҵIJÙ×÷ϵͳÊÇwin2000 server)
µ«ÊÇÆæ¹ÖµÄÊÇÔÚ¾ÖÓòÍøµÄÆäËû» ......