php - Mysql add column from another table (no reference id)

953

Table small contains
column A varchar(10) column B varchar(20)

Table skeleton contains
column A varchar(10) column B varchar(20) column C varchar(30) column D varchar(40)

I want to add column C varchar(30) from table skeleton to small table.

Please note skeleton contains no data and two table doesn't have any common key to join.

@Ultimater thanks.. but that will not solve the issue.. Actually I don't know which column will be needed to add, it will be based on source data.... small table is actually a dynamic table which will grow in times.... skeleton table is like a schema table to get exact column name and type from it. Hope you understand....

@update my data feed for small table will be an XML file I do have XSD file also... so if anybody could give any XSD reader library for PHP other than xsdreader - (which I tried without much success) then it will equally solve my problem... Hope You Understand.

285

Answer

Solution:

If I understood you correctly, all you're trying to do is add another column to an already existing table. This is quite simple with phpMyAdmin for example. In your case all you'd need is:

ALTER TABLE  `small` ADD `C` VARCHAR( 30 ) NOT NULL

People are also looking for solutions to the problem: php - wordpress add_option is not working

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.