I have database in mysql & have maintain 3 columns i.e. ID , name, slug.
Slug column is same as name but here I put combination of name column. Suppose if name is Micky Mehta then in slug I want it should show micky-mehta. In slug I want everything in small letters & if space then it should be replaced with dash. All this because I want SEO friendly url for my site. Now I can do this with program when new products gets added but is it also possible If I can directly do that with mySQL? I mean is there any function in mySQL which perform this kind of task?
3
Answers
Try This
example-
You can update data to fit your scheme:
If you want it to happen automatically every time you add a new row or update an existing row, you can use triggers:
In MySQL 5.7, they now have generated columns, so you can do the same thing without writing triggers:
You can also do this with your programming language. If you are coding in php you can do it as below
Take a new variable say
$slug
Insert the
$slug
variable in your database table along with thename
column(consideringid
is auto incremented column.