Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Á½ÖÖSQLÓï¾ä ЧÂÊÎÊÌâ

Çé¿öÊÇÒ»Õűí(T)ÄÚ£¬Ã¿Ìõ¼Ç¼ÓÐÒ»¸öÀàÐÍ×ֶΣ¬µ±°´ÀàÐÍ×Ö¶ÎÀ´·ÖÀà²éѯ²¢·ÖÒ³´¦Àíʱ
(±íTÄÚµÄÀàÐÍÊÇÖ¸ÏòÁíÒ»ÕÅÀàÐͱíµÄÒ»¸öIDÖµ)
ÎÒÏëµ½ÁËÁ½ÖÖ·½Ê½£»

»·¾³£ºPHP+MYSQL

1¡¢PHP ÏÈÖ´ÐÐÒ»Ìõ²éѯµÃµ½Ö¸¶¨ÀàÐ͵ļǼÌõ£¬ ÔÙÖ´ÐÐÒ»´Î²éѯ »ñÈ¡ËùÓÐÖ¸¶¨ÀàÐ͵ļǼ£¨MYSQL°´·ÖÒ³·µ»Ø£©
SQL code:

--²éѯÀàÐÍID Ϊ 3µÄËùÓмǼµÄÌõÊý
select count(*) from pstbl where pstbl.typeid=3;

-- ·µ»Ø·ÖÒ³µÚ2Ò³µÄÄÚÈÝ£¨20£©Ìõ
select * from pstbl where pstbl.typeid =3 limit 1,20;



2¡¢PHP Ö»Ö´ÐÐÒ»Ìõ²éѯÓï¾ä£¬Ã¿Ìõ¼Ç¼ÀïÃæ°üº¬×Å×ܼǼÌõÊý
SQL code:

--²éѯÀàÐÍID Ϊ 3µÄËùÓмǼ´øÌõÊý, ÇÒ·µ»Ø·ÖÒ³µÚ2Ò³µÄÄÚÈÝ£¨20£©Ìõ
select ps.*,(select count(*) from pstbl where pstbl.typeid=3) as total
from pstbl as ps where ps.typeid=3 limit 1,20;



²»ÏþµÃÕâÁ½ÖÖ·½Ê½¶ÔÕûÌåЧÂÊÓкÎÓ°Ïì  ¾ÍÊÇ·Ö¿ª¶àÌõÖ´ÐкÃһЩÄØ£¬»¹ÊǸ´ºÏÖ´ÐÐÒ»´ÎÍê³ÉºÃЩ
ÒòΪ·Ö¿ªÊ±£¬Óï¾ä±È½Ï¼òµ¥£¬Á¬ÆðÀ´²éѯʱÓï¾ä½Ï¸´ÔÓ£¬»á²»»áÖ´ÐÐʱ¼ä¹ý³¤
ÓõÚ2ÖֵĻ°£¬ÎÒʵ¼ÊÔËÓÃÉÏ»¹Òª¼ÓÉϲéѯÁíÒ»ÕÅID£¬Í¬Ê±¿¼Âǵ½¾¡Á¿ÕÒÏàÁÙµÄÒ»ÖÖÀàÐÍ£¬¾Í˵µ±Ö¸¶¨µÄÀàÐÍID²»´æÔÚ£¬
»òÕßδָ¶¨¾Í×Ô¶¯·µ»ØÏàÁÙµÄÒ»ÖÖÀàÐÍ

ʵ¼ÊÉÏÔËÓõÄÓï¾ä ʾÀý
SQL code



Code highlighting produced by Actipro CodeHighlighter (freeware)
http://ww


Ïà¹ØÎÊ´ð£º

sql ʱ¼äÎÊÌâ

sql table±íÓиöÎı¾ÀàÐ͵Äa×ֶΣ¬´æ´¢µÄÄÚÈÝÈ«²¿ÊÇÊý×Ö£¬ÀýÈç2009001£¬2008578ÕâÑùµÄ¸ñʽ£»b×Ö¶ÎÎı¾ÀàÐÍ£¬´æµÄÒ²ÊÇÊý×ÖÀýÈç 001£¬123
aspÀïÃæ strday=100£¬strb=001

ÎÒÏë¶Á³ö£¬´Óa×ֶεÄÊý×Ö°´´óµ½Ð¡µÄË ......

sqlÎļþ£¨Êý¾Ýº¬ÖÐÎÄ£©DOSÃüÁî´°¿ÚÎÞ·¨µ¼ÈëÎÊÌâ

ÎÒÓõÄÊÇmysql5.1£¬Êý¾Ý¿â×Ö·û¼¯Îªutf8

ͨ¹ýdosÃüÁîÐе¼ÈëSQLÎļþ ³ö´í£¬ÎÞ·¨µ¼Èë¡£

½«SQLÎļþÖеÄÊý¾ÝÈ«²¿Ê¹ÓÃÓ¢ÎÄ ¿ÉÒÔµ¼Èë

ÇëÎÊÎÊÌâÔÚÄÄ£¿
×°¸öÖÐÎÄÈí¼þ¼´¿É.

ºÜ¶àÄêÒÔÇ°,Óùý¸öÒ»¸ ......

sql ÎÊÌâ

DateTime startTime=DateTime(em_1.Text)
DateTime endTime=DateTime(em_2.Text)

string sql
sql = dw_1.GetSQLSelect()+"Where (StartTime> '"+startTime+"') and (EndTime ......

Çë½ÌÒ»¸ösqlÊý¾ÝɸѡÎÊÌâ

ÓÐ×Ö¶Î
ÈÕÆÚ£¬id

ÈÕÆÚ²»Öظ´£¬id ÓÐÖظ´

ÐèҪɸѡ³ö ÿ¸öidÀïÃæÈÕÆÚ×îÔçµÄÊý¾Ý¡£
SQL code:
select * from ±í t where not exists(select 1 from ±í where t.ÈÕÆÚ>ÈÕÆÚ and id=t.id)

SQL ......

sqlÓï¾äÖÐÄܲ»ÄÜÕâÑùÅÅÐò£¿

Êý¾Ý±í¡¾biao¡¿£¬
×ֶΣºid¡¢myname¡¢mytxt
mytxtÄÚÈݸñʽÐÎÈ磺n|abcd¡££¨ÀýÈ磺1|ÁõµÂ»ª£¬2|Èδﻪ£¬3|αÌϼ£¬4|Âõ¿Ë@½Ü¿ËÑ·£©

ÎÒÏÖÔÚÏ£Íû¶Á¼Ç¼³öÀ´ºó£¬°´ÕÕ[mytxt]×Ö¶ÎÀïµÄÊúÏߣ¨|£©Ç°ÃæµÄÄǸöÊý× ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ