2011-01-07 39 views
9

我已經在網上查找了我的答案,也許我只是在做錯事。我在我的MySQL表中有一列,我需要用我的SQL查詢中的文本字符串替換所有NULL值使用phpMyAdmin。我不希望輸出出現這種方式,我想實際上用文本字符串替換空值。如何替換特定表中特定字段中的所有NULL值?

我已經試過

UPDATE `tablename` SET fieldname = replace (fieldname, "", "textstring") 

我已經閱讀了關於

SELECT ISNULL(field,"replacetext) 

但這僅顯示輸出,但在表中實際上並沒有取代它。

我無法弄清楚,我浪費了很多時間試圖找到答案。

回答

19
update tablename set fieldname = "textstring" where fieldname is null; 
+0

打我吧:)刪除我的答案。 – kander 2011-01-07 19:05:06

+0

我需要200才能獲得更少的廣告(: – 2011-01-07 19:10:49

5

你試過

UPDATE `tablename` SET fieldname = '' where fieldname is null 
相關問題