[nSLUG] MySQL find/replace

Herb htheriault at gmail.com
Mon Jun 28 10:51:45 ADT 2010


That was the problem. Thanks :)

On Sat, Jun 26, 2010 at 9:50 PM, Miles Thompson <milesthom at gmail.com> wrote:
>
>
> Did you have a look at IS NULL and isnull() ?
> http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html
>
> It's a trap I've fallen into before - "NULL" is not a real null, it's a
> string.
>
> How about this, untested of course:
> update wp_postmeta set meta_key = "my replacement text" where
> isnull(meta_key);
>
> Cheers - Miles
>
> On Sat, Jun 26, 2010 at 7:14 PM, Herb <htheriault at gmail.com> wrote:
>>
>> Hi all,
>>
>> I'm migrating an aging drupal site to wordpress and am stuck on one of
>> my last sql tasks, involving replacing a field in one of the mysql
>> tables.
>>
>>
>> =======
>> mysql> update wp_postmeta set meta_key = replace(meta_key,"NULL","my
>> replacement text");
>> Query OK, 0 rows affected (0.00 sec)
>> Rows matched: 549  Changed: 0  Warnings: 0
>> =======
>>
>> It's matching the entire column instead of the fields that are NULL
>>
>> Attempts at changing the first bracketed field to NULL as well
>> ("NULL","NULL","my replacement text") actually fills the column with
>> the replacement.
>>
>> Can anyone shed some light on what I'm missing?
>>
>> Thanks,
>>
>> Herb
>> _______________________________________________
>> nSLUG mailing list
>> nSLUG at nslug.ns.ca
>> http://nslug.ns.ca/mailman/listinfo/nslug
>
>
>
> --
> Miles Thompson
> ~~~~~~~~~~~~~~~~~~~~~~~~~~
> "The piano keys are black and white,
> But they sound like a million colours in your mind"
> Spider's Web - Katie Melua
>
> _______________________________________________
> nSLUG mailing list
> nSLUG at nslug.ns.ca
> http://nslug.ns.ca/mailman/listinfo/nslug
>
>



More information about the nSLUG mailing list