Merge MySql fields of table with phpmyadmin and sql statement

Hellow all,

Is it possible to merge fields in a table to a new table? Let me describe the situation. I have an external sql dump that has a birthday table with 18000 birthday dates. Like this:

tablename: birthdays
field 1: id (int 10)
field 2: day (double)
field 3: month (double)
field 4: year (varchar 255)

a record would be like this

| id | day | month | year |
| 1  | 9     | 10      | 1981 |

I'd like to merge these fields (and the contents of the fields) with an sql statement (phpmyadmin) to this:

tablename: birthdays
field1: id (int 10)
field2: birthday (date)

a record would be like this

| id | birthday      |
| 1  | 1981-10-09 |

Can this be done? And how?

greetz,
walter
LVL 8
wal_toorAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
burningmaceConnect With a Mentor Commented:
Sorry, forgetting MySQL requires concat.

UPDATE birthdays SET birthdate = concat(year, '-', month, '-', day);

Remember that you need birthdate to be a VARCHAR column.
0
 
burningmaceCommented:
Create a new column in your table called BirthdayNew.

UPDATE birthdays SET BirthdayNew = year + '-' + month + '-' + day

Then delete the old columns and rename BirthdayNew to whatever you want.
0
 
wal_toorAuthor Commented:
Hmm zero rows affected? Should this sql statement handle all the 12000 records?

greetz,
walter
0
 
wal_toorAuthor Commented:
Great!
0
All Courses

From novice to tech pro — start learning today.