sqlÎÊÌâ - ÆäËûÊý¾Ý¿â¿ª·¢ / MySQL/Postgresql
ÔõôÑù²éѯÁ¬½Ó2¸ö±íÖ®ºó µÃ³öµÄбí
ÀýÈç A±í£º·¢¼þÈËID Óʼþ±àºÅ ÓʼþÄÚÈÝ ÊÕ¼þÈËID ·¢¼þʱ¼ä
B±í£ºÊÕ¼þÈËID Óʼþ±àºÅ ÊÕ¼þʱ¼ä
Ê×ÏÈ×öA BµÄÁ¬½Ó²éѯ ¼´ Óʼþ±àºÅÏàµÈ
²é³ö£º·¢¼þÈËID Óʼþ±àºÅ ÓʼþÄÚÈÝ ÊÕ¼þÈËID ·¢¼þʱ¼ä ÊÕ¼þʱ¼ä
È»ºóÔÙ ²é·¢¼þÈËIDÊÇij¸öÌØ¶¨ÖµµÄ ËùÓÐÄÚÈÝ ÈçºÎ×öµ½
SQL code:
select A±í.·¢¼þÈËID,A±í.Óʼþ±àºÅ,A±í.ÓʼþÄÚÈÝ,A±í.ÊÕ¼þÈËID,A±í.·¢¼þʱ¼ä,B±í.ÊÕ¼þʱ¼ä
from A±í inner join B±í on A±í.Óʼþ±àºÅ = B±í.Óʼþ±àºÅ
where A±í.·¢¼þÈËID=123456
½¨ÒéÄãÁгöÄãµÄ±í½á¹¹£¬²¢Ìṩ²âÊÔÊý¾ÝÒÔ¼°»ùÓÚÕâЩ²âÊÔÊý¾ÝµÄËù¶ÔÓ¦ÕýÈ·½á¹û¡£
²Î¿¼Ò»ÏÂÕâ¸öÌù×ÓµÄÌáÎÊ·½Ê½http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
1. ÄãµÄ create table xxx .. Óï¾ä
2. ÄãµÄ insert into xxx ... Óï¾ä
3. ½á¹ûÊÇʲôÑù£¬£¨²¢¸øÒÔ¼òµ¥µÄËã·¨ÃèÊö£©
4. ÄãÓõÄÊý¾Ý¿âÃû³ÆºÍ°æ±¾(¾³£ÓÐÈËÔÚMS SQL server°æÎÊ MySQL)
ÕâÑùÏë°ïÄãµÄÈË¿ÉÒÔÖ±½Ó´î½¨ºÍÄãÏàͬµÄ»·¾³£¬²¢ÔÚ¸ø³ö·½°¸Ç°½øÐвâÊÔ£¬±ÜÃâÎÄ×ÖÃèÊöÀí½âÉϵÄÎó²î¡£
Ïà¹ØÎÊ´ð£º
ÎÒÒ»¸öÏîÄ¿£¬Óиö²åÈë²Ù×÷£¬¾ßÌåÊÇÕâÑùµÄ£º
ÎÒÓнø»õÐÅÏ¢±í¡£ÔÚ³ö»õʱѡÔñÏàÓ¦µÄ½ø»õÐÅÏ¢£¬ÊäÈëÊýÁ¿£¬Ñ¡Ôñ²¿Ãź󣬵㱣´æ°´Å¥£¬ÓÉÓÚÍøÂçÑÓʱ£¬µãÒ»ÏÂûÓз´Ó³£¬ÓÚÊÇÓû§¾ÍÓÖµãһϣ¬µ¼ÖÂÒ»´Î²åÈëÁËÁ½Ìõ¼Ç¼:
Àý£º
......
ÏÖÔÚÓÐÁ½ÕÅ±í£ºÎÄÕÂÖ÷±íA(articleId,articleTitle)£¬ÎÄÕÂÆÀÂÛ±íB(commentId,articleId,commentTitle)
ÏÖÔÚÎÒÏëʵÏÖÕâÑùµÄ¹¦ÄÜ£ºÁгöÎÄÕÂÁÐ±í£¬ÆäÖÐÿƪÎÄÕ±êÌâÏÂÃæÁгö´ËÎÄÕµÄǰ2¸öÎÄÕÂÆÀÂÛ£¬ÇëÎÊsqlÓï¾äÔõôд°¡ ......
ÇëÎÊ
Ìí¼ÓÐÂÊý¾ÝÔ´->Êý¾Ý¿â->Ìí¼ÓÁ¬½Ó
Õâ¸ö½çÃæÏ£¬Êý¾ÝÔ´Ñ¡Ôñ£ºMicrosoft SQL Server (SqlClient)£»
·þÎñÆ÷Ãû£º
Ó¦¸ÃÐ´Ê²Ã´ÄØ£¿
ÓÐËÖªµÀ£¿¶àл¸÷λ£¡£¡
Äãµ½µ×ÊÇÒªÁ¬mysql»¹ÊÇmssql£¿
ÒýÓÃ
ÇëÎÊ
......
3̨µçÄÔ£¬ÆäÖÐһ̨×÷ΪMYSQL·þÎñÆ÷£¬ÁíÍâ2̨ΪTOMCAT·þÎñÆ÷¡£
MYSQL·þÎñÆ÷ÀïÓÐÒ»Ìõ¼Ç¼£¬ IDΪ10.
ÏÖÔÚ2̨TOMCATͬʱ£¨100%£©·¢ÆðÐÞ¸ÄMYSQLÀïIDΪ10µÄÄÇÌõ¼Ç¼£¬±ÈÈçÐ޸ĴËID¼Ç¼ÀïijһÏîµÄÄÚÈÝ¡£ ±ÈÈçTOMCAT 1Ò ......
ÎÒÏë²éѯ³öÿÌìÊý¾ÝµÄ×î´óµÄÒ»¸öÖµ¡£±íµÄ¸ñʽÈçÏÂ
±íÃû: hisdata
×Ö¶Î ±àºÅ Öµ ״̬ ʱ¼ä
Id value state dattime
101 32.3 0 ......