Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6709427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:52:49+00:00 2026-05-26T07:52:49+00:00

Let assume we’ve database table My_table with (id-name) CREATE TABLE `drink` ( `id` int(5)

  • 0

Let assume we’ve database table My_table with (id-name)

CREATE TABLE `drink` (
`id` int(5) NOT NULL auto_increment,
`name` varchar(64) NOT NULL default '',
PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9034 ;

INSERT INTO `My_table` VALUES (1, 'my name is someone');

How to automate adding new fields using php or something else so that it can be (id-new-name)

and where new = name after we replace spaces to - using

$new = str_replace(' ', '-', trim($name));

so the table become

CREATE TABLE `drink` (
`id` int(5) NOT NULL auto_increment,
`new` varchar(64) NOT NULL default '',
`name` varchar(64) NOT NULL default '',
PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=9034 ;

INSERT INTO `My_table` VALUES (1, 'my-name-is-someone', 'my name is someone');

I’d like to operate it cause it has half million of lines and impossible to do it manually
so any idea!

Thanks for help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:52:50+00:00Added an answer on May 26, 2026 at 7:52 am

    You might want to do that:

    1. Adding a new column to the table:

      ALTER TABLE drink ADD new varchar(100) after id;

    2. Setting values for the new column using the pattern you described:

      UPDATE drink SET new = REPLACE(name, ‘ ‘, ‘-‘);

    RESOURCES:

    • http://dev.mysql.com/doc/refman/5.5/en/alter-table.html

    • http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let assume we have string name = stackoverflow.com; how to convert this string int
Let's assume, we create a stored procedure that is supposed to retrieve customer details
Let's assume this class in C#: public class LimitedList<T> : List<T> { private int
Let's assume I have a database with two tables: categories and articles . Every
Let's assume I extract some set of data. i.e. SELECT A, date FROM table
Let's assume you've got a nosql database - redis, cassandra, mongodb. And you need
Let's assume I have the following field: ' name sub _blah ' I can
I have a table in a database that contains two fields id name I
Let's assume you have a table and the following Jquery code var rows =
Let us assume, int *p; int a = 100; p = &a; What will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.