Answer the question
In order to leave comments, you need to log in
Transferring data from one table to another?
The crux of the matter is this.
There are three bases!
Two of which need to be added to one.
Each base has different columns.
1 base id, name, pass, type, email
2 base id, user, password, ip, email
3 base (To which you need to add the bases above) id, username, password, email, ip, db
How to implement it!?
For example, if there is no ip, email in 1 database, then null will be added
. Is it possible to do this?
Answer the question
In order to leave comments, you need to log in
You write "base" and actually the table?
INSERT INTO tbl3 (username, password, email, ip)
SELECT name, pass, email, null FROM tbl1
INSERT INTO tbl3 (username, password, email, ip)
SELECT user, password, email, ip FROM tbl2
INSERT IGNORE INTO `base_3` (
SELECT
`id` AS `id`,
`name` AS `username`,
`pass` AS `password`,
`email` AS `email`,
NULL AS `ip`,
NULL AS `db`
FROM `base_1`
UNION
SELECT
`id` AS `id`,
`user` AS `username`,
`password` AS `password`,
`email` AS `email`,
`ip` AS `ip`,
NULL AS `db`
FROM `base_2`
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question