0

I'm really bad in MySQL, and I really don't know is it even possible. But I have 6k records and don't want to do it manually.

I have to columns: Name and Slug. Names can be different, for example Dancer, Hip Hop, Rock (hard).

And what I want to do is for each record change Slug automatically depending on Name, with converting to slug. For example, for Dancer do dancer, for Hip Hop => hip-hop, for Rock (hard) => rock-hard.

Is it even possible?

Andrey Drozdov
  • 571
  • 1
  • 5
  • 22

1 Answers1

1

You should be able to update all your slugs in 1 query using LCASE() and REPLACE(). Something like this should work:

update mytable set Slug=lcase(replace(Name, ' ', '-'));
Asaph
  • 159,146
  • 25
  • 197
  • 199