<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
	<title>資料庫</title>
	<link>http://blog.roodo.com/rss20/topic/topic_article_12445.xml</link>
	<description>探討各式資料庫系統及 SQL 語法等。</description>
	<language>zh-tw</language>
	<generator>Roodo Blog System</generator>
	<copyright>All Rights Reserved</copyright>
	<item>
		<title>TWPUG問答: SQL 文字搜尋 / 石頭閒語</title>
		<description> Tags: sql like 
 
I try to write a searching engine with php and mysql. Somehow I always get error messages. Here is my code: 
 $sql = &quot;SELECT * FROM `General` WHERE `Item_Name` LIKE $Name&quot;;  
  TWPUG::資料庫討論區  
 

 
SQL syntax error.
 
 
 The field-name should be put in double-quote. It means case-sensitive. 
 The  LIKE  only applies for text-based type field, therefore you need to put content in single-quote. Besides,  LIKE  must be used with &#039;%&#039;. 
 
</description>
		<link>http://blog.roodo.com/rocksaying/archives/3284073.html</link>
		<author>info@blog.roodo.com&lt;info@blog.roodo.com&gt;</author>
		<category>網路/3C</category>
		<pubDate>Mon, 21 May 2007 16:03:33 +0800</pubDate>
					</item>
	<item>
		<title>以 replace 修正整批記錄的錯字 / 石頭閒語</title>
		<description> 
今天修正了公司客戶資料庫中的電話資料。主要是將中間的連接線 (-) 拿掉，這是人工輸入的，但實際上根本用不著。不是很難的動作，用 replace() 就搞得定。
 
 
比較麻煩的是電話有二組，但有不少資料記錄漏掉第一組電話。起因於門市人員在建檔時，常常把第一組電話當市話號碼欄位、第二組電話當手機號碼欄位。當碰到客戶只填手機而不填家中電話時，就會空下第一組電話欄位。因為資料庫系統以第一組電話欄位為主要電話，所以這會帶來些麻煩。例如，在列印單據時，如果單據只顯示一個電話時，資料庫系統只會取紀錄中的第一組電話欄位。如此一來就有不少單據上沒有顯示客戶電話。所以這次也順便把那些沒有第一組電話欄位的紀錄一起補上 (以第二組電話補上) ，這就要用 CASE 敘述了。
  
 
UPDATE customer
SET
	tel1 = REPLACE(CASE WHEN tel1 IS NULL THEN tel2 ELSE tel1 END, &#039;-&#039;, &#039;&#039;)
	tel2 = REPLACE(tel2, &#039;-&#039;, &#039;&#039;),
 </description>
		<link>http://blog.roodo.com/rocksaying/archives/2815495.html</link>
		<author>info@blog.roodo.com&lt;info@blog.roodo.com&gt;</author>
		<category>網路/3C</category>
		<pubDate>Wed, 07 Mar 2007 14:45:20 +0800</pubDate>
					</item>
	<item>
		<title>sp_attach_db / Thinking more...</title>
		<description>用法很簡單...

 
EXEC sp_attach_db @dbname = N&#039;pubs&#039;, 
   @filename1 = N&#039;c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs.mdf&#039;, 
   @filename2 = N&#039;c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log.ldf&#039;
 

在 osql command line mode 下輸入以後，記得再輸入 go，表示執行指令。

參考資料：
   sp_attach_db   
</description>
		<link>http://blog.roodo.com/thinkingmore/archives/1724528.html</link>
		<author>info@blog.roodo.com&lt;info@blog.roodo.com&gt;</author>
		<category>網路/3C</category>
		<pubDate>Wed, 07 Jun 2006 23:16:05 +0800</pubDate>
					</item>
</channel>
</rss>