Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

copy column data to another column sql with creating slugs

## Add New Column then UPDATE Old Table Data to New table with Slug type

## Syntax
ALTER TABLE `tblname` ADD `column_slug` VARCHAR(255) NOT NULL AFTER `column_name`;
UPDATE `tblname` SET `column_slug` = replace(lower(column_name), ' ', '-');

## Example
ALTER TABLE `product` ADD `product_slug` VARCHAR(255) NOT NULL AFTER `productname`;
UPDATE `product` SET `product_slug` = replace(lower(productname), ' ', '-');
 
PREVIOUS NEXT
Tagged: #copy #column #data #column #sql #creating #slugs
ADD COMMENT
Topic
Name
7+7 =