ÓÃÌæ´ú±äÁ¿µÄ·½Ê½±àдsqlÓï¾ä
SQL> select * from dept where deptno=&tt;
Enter value for tt:20
DEPTNO DNAME LOC
------ -------------- -------------
10 ACCOUNTING NEW YORK
ÕâÑùÎÞÂÛÊäÈë¶àÉÙ´ÎttµÄÖµ£¬ÏµÍ³Ö»½¨Á¢Ò»¸öÖ´Ðмƻ®£¬Ìá¸ßÁËÖ´ÐеÄЧÂÊ¡£
¶øÆÕֱͨ½Ó¸øÖµµÄд·¨ÒªÃ¿´Î¶¼½¨Á¢Ò»¸öÖ´Ðмƻ®
Ïà¹ØÎĵµ£º
ÒÔÇ°¶ÔÓÚSql ServerÖÐCaseÃüÁîµÄÓ÷¨Ò»Ö±²»ÊǺÜÁ˽⣬½ñÌìͨ¹ýÉÏÍø²éÁËһЩ×ÊÁÏ£¬½«Case»ù±¾µÄÓ÷¨×ܽáһϡ£
CaseÃüÁîÓÐÁ½ÖÖÓï·¨£º
A£©CASE<ÔËËãʽ>
WHEN <ÔËËãʽ> THEN <ÔËËãʽ>
……
WHEN <ÔËËãʽ> THEN <ÔËËãʽ>
[ELSE<ÔËËãʽ> ......
Ó¦Óû·¾³¾ÍÊdzÌÐòÔÚÁ½¸öµØµãÔËÐеģ¬Á½±ß¶¼Òª²Ù×÷ÐÞ¸ÄÊý¾Ý£¬Á½µØͨ¹ý²¦ºÅÁ¬½Ó£¬ÊÇÓÃsql2000·½±ã£¬»¹ÊÇ2005·½±ã£¬ÓÃ2̨»úÆ÷¾Í¿ÉÒÔ»¹ÊÇ3̨»úÆ÷£¬Óô¥·¢Æ÷»¹ÊDZðµÄ·½·¨ÊµÏÖ£¿SQL codeÒÔÏÂʵÏÖ¸´ÖƲ½Ö裨ÒÔ¿ìÕÕ¸´ÖÆΪÀý£©
ÔËÐÐƽ̨SQL SERVER 2005
Ò»¡¢×¼±¸¹¤×÷£º
1£®½¨Á¢Ò»¸ö WINDOWS Óû§£¬ÉèÖÃΪ¹ÜÀíԱȨÏÞ£¬²¢ÉèÖÃÃÜ ......
Êý¾Ý¶¨ÒåÓïÑÔ£¨DDL£©£º
1£©´´½¨Êý¾Ý¿â£¨create£©£ºcreate database database-name;
eg. create database test;
2£©É¾³ýÊý¾Ý¿â£ºdrop database dbname;
& ......
SQLÖÐÎÄÎÊÅÅÐò
Ê×ÏÈ°ÑÕâЩÐÅÏ¢ÔÚeditplusÖУ¬×ª»»ÎªÒ»ÁУ¬¿½±´µ½excelÖУ¬¿½±´ºó¼Ç×ÅÔÚµÚÒ»ÐÐÇ°²åÈëÒ»ÐУ¬×÷ΪÁбêÍ·£¬ÀýÈçΪname£¬È»ºóÔÚsqlÖбíÖУ¬µ¼ÈëÊý¾Ý£¬Éú³ÉÒ»¸öÐÂ±í£¬ÀýÈçfenlei£¬´ò¿ªsqlÓï¾äÐУ¬Ö´ÐУº
SELECT *
from Fenlei
ORDER BY name COLLATE Chinese_PRC_CS_AS_KS_WS
......
Õâ¾ÍÒª´ÓË«ÒýºÅºÍµ¥ÒýºÅµÄ×÷Óý²Æð£º
Ë«ÒýºÅÀïÃæµÄ×ֶλᾹý±àÒëÆ÷½âÊÍÈ»ºóÔÙµ±×÷HTML´úÂëÊä³ö£¬µ«Êǵ¥ÒýºÅÀïÃæµÄ²»ÐèÒª½âÊÍ£¬Ö±½ÓÊä³ö¡£ÀýÈ磺
$abc='I love u';
echo $abc //½á¹ûÊÇ:I love u
echo '$abc' //½á¹ûÊ ......