2008年2月28日 星期四

MySQL REPLACE 功能

update [table] set [field]=replace([field],’[str_search]’,'[str_replace]’);
今天在轉換編輯器的時候,突然多出來的需求。

for example:

update news set content=replace(content,'\n','
')

-----

2008年2月20日 星期三

MySQL 預設時間值 欄位

用以下的語法建立即可

CREATE TABLE `TEMP` (
`MODIFY_TIME` TIMESTAMP(14) ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
)

要注意的是,一個資料表,只能夠有一個CURRENT_TIMESTAMP的欄位