sql replace Ìæ»»×Ö¶ÎÖв¿·ÝÖ¸¶¨ÄÚÈÝ
sql replace Ìæ»»×Ö¶ÎÖв¿·ÝÖ¸¶¨ÄÚÈÝ
´´½¨Êý¾Ý¿â½Ì³Ì
create database cnnet;
´´½¨Êý¾Ý±í
CREATE TABLE `cnnet`.`test` (
`id` INT( 4 ) NOT NULL AUTO_INCREMENT ,
`url` VARCHAR( 50 ) NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM
²å¼¸ÌõÊý¾Ý:
INSERT INTO `test` (`id`, `url`) VALUES
(1, 'www.1aa.cm'),
(2, 'www.1aa.cm'),
(3, 'www.1aa.cm'),
(4, 'www.1aa.cm'),
(5, 'www.111cn.net'),
(6, 'www.111cn.net');
ÏÂÃæÎÒÃÇÀ´¿´¿´sql replace Ìæ»»×Ö¶ÎÖв¿·ÝÖ¸¶¨ÄÚÈÝÈëÃŽ̳̰ɡ£
´´½¨Êý¾Ý¿âÁ¬½Ó
*/
$cn = mysql½Ì³Ì_connect('127.0.0.1','root','root') or die('Êý¾Ý¿âÁ¬½Óʧ°Ü');
$sql = "select * from test where url like '%1aa.cm%' ";
$result = mysql_db_query( 'cnnet',$sql,$cn );
while( $rs = mysql_fetch_array( $result ) )
{
echo $rs['url'],'<br />';
}
/*
Êä³ö½á¹û
www.1aa.cm
www.1aa.cm
www.1aa.cm
www.1aa.cm
ºÃ½á¹û³öÀ´ÁË£¬ÎÒÃÇÕýʽ½øÐÐÕýÌ⣬replaceÌæ»»ÄÚÈÝ£¬ÎÒÃÇÒªÇó°Ñ1aa.cmÈ«²¿Ìæ»»³É111cn.net
*/
$sqlReplace ="update test set url = replace('1aa.cm','111cn.net',url) WHERE url like '%1aa.cm%'";
mysql_db_query('cnnet',$sqlReplace,$cn);
if( 1 )
{
$sql = "select * from test ";
$query = mysql_db_query('cnnet',$sql,$cn );
while( $row = mysql_fetch_array( $query ) )
{
echo $rs['url'],'<br />';
}
}
else
{
echo '¼ì²éÄãµÄsqlÓï¾ä£¬Ð»Ð»';
}
/*
Êä³ö½á¹û£º
www.111cn.net
www.111cn.net
111cn.net
111cn.net
111cn.net
111cn.net
×¢Ã÷±¾Õ¾Ô´´ÎÄÕÂתÔØ×¢Ã÷À´Ô´www.111cn.net
Ïà¹ØÎĵµ£º
<!--MySql Çý¶¯³ÌÐò eg. mysql-connector-java-5.0.4-bin.jar-->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- JDBC URL -->
......
ÎÄÕÂÀ´Ô´£ºIT¹¤³Ì¼¼ÊõÍø http://www.systhinker.com/?viewnews-11609
ÌúÂÉÒ»£ºÌìÏÂûÓÐÃâ·ÑµÄÎç²Í£¬Ê¹ÓÃË÷ÒýÊÇÐèÒª¸¶³ö´ú¼ÛµÄ¡£
¡¡¡¡Ë÷ÒýµÄÓŵãÓÐÄ¿¹²¶Ã£¬µ«ÊÇ£¬È´ºÜÉÙÓÐÈ˹ØÐĹý²ÉÓÃË÷ÒýËùÐèÒª¸¶³öµÄ³É±¾¡£ÈôÊý¾Ý¿â¹ÜÀíÔ±Äܹ»¶ÔË÷ÒýËùÐèÒª¸¶³öµÄ´ú¼ÛÓÐÒ»¸ö³ä·ÖµÄÈÏʶ£¬Ò²¾Í²»» ......
1. ¿ÉÒÔÓýű¾±¸·Ý
¡¡¡¡manger studio--ÓÒ¼üÄãµÄÊý¾Ý¿â--ÈÎÎñ--Éú³É½Å±¾
¡¡¡¡Ôڽű¾Éú³ÉÏòµ¼µÄ"Ñ¡Ôñ¶ÔÏóÀàÐÍ"²½ÖèÖÐ, ½«"´æ´¢¹ý³Ì"Ñ¡ÉÏ, ÔÚ½ÓÏÂÀ´µÄ"Ñ¡Ôñ´æ´¢¹ý³Ì"µÄ²½ÖèÖÐ, Ñ¡ÔñËùÓеĴ洢¹ý³Ì(»òÕßÄãÒª¸´ÖƵĴ洢¹ý³Ì)
¡¡¡¡Íê³Éºó, ËùÓд洢¹ý³ÌµÄ½Å±¾»áÉú³ÉÔÚÒ»¸öеIJéѯ´°¿ÚÖÐ, ¹ØµôÉú³É½Å±¾Ïòµ¼, ÔÚÉú³ÉµÄ´æ´¢¹ý³Ì ......
¶¨Ò壺 ºÎΪ´¥·¢Æ÷£¿ÔÚSQL ServerÀïÃæÒ²¾ÍÊǶÔijһ¸ö±íµÄÒ»¶¨µÄ²Ù×÷£¬´¥·¢Ä³ÖÖÌõ¼þ£¬´Ó¶øÖ´ÐеÄÒ»¶Î³ÌÐò¡£´¥·¢Æ÷ÊÇÒ»¸öÌØÊâµÄ´æ´¢¹ý³Ì¡£
³£¼ûµÄ´¥·¢Æ÷ÓÐÈýÖÖ£º·Ö±ðÓ¦ÓÃÓÚInsert , Update , Delete ʼþ¡£(SQL Server 2000¶¨ÒåÁËеĴ¥·¢Æ÷£¬Õ ......
¡¾»ã×Ü¡¿SQL CODE --- ¾µä·¾«²Ê
Êý¾Ý²Ù×÷Àà SQLHelper.cs
ÎÞÏÞ¼¶·ÖÀà ´æ´¢¹ý³Ì
°ÙÍò¼¶·ÖÒ³´æ´¢
SQL¾µä¶ÌС´úÂëÊÕ¼¯
ѧÉú±í ¿Î³Ì±í ³É¼¨±í ½Ìʦ±í
50¸ö³£ÓÃsqlÓï¾ä
SQL SERVER
ÓëACCESS¡¢EXCELµÄÊý¾Ýת»»
Óαê
¸ù¾Ý²»Í¬µÄÌõ¼þ²éѯ²»Í¬µÄ±í
INNER JOIN Óï·¨
master.dbo.sp ......