Reputation: 833
I have changed the structure of my database, and need to copy data from the old instance to the new one. Since the columns of the tables have been altered I can't simply export/import the data.
I have been somewhat successful with moving the data, but I am now experiencing the following problem. Consider this sample query:
insert into gene_results (test_kit_id)
select id
from test_kits
where tag = xploreyou_db_copy.gene_results.tag;
I receive the following error: Unknown column 'xploreyou_db_copy.gene_results.tag' in 'where clause'
I am absolutely positive that the column exists, and I have been successful with this syntax before. I am very confused as to why this suddenly doesn't work. I'm writing my queries in Sequel Pro. The databases are located on the same server.
Upvotes: 0
Views: 49
Reputation: 13971
where tag = xploreyou_db_copy.gene_results.tag;
Use join instead of where in above query
INSERT INTO gene_results
(test_kit_id)
SELECT test_kits.id
FROM gene_results AS gene_results_1 INNER JOIN
test_kits ON gene_results_1.tag = test_kits.tag
Upvotes: 1
Reputation: 13700
You need to join with that database
insert into gene_results (test_kit_id)
select t1.id
from test_kits as t1 inner join xploreyou_db_copy.gene_results as t2
on t1.tag = t2.tag;
Upvotes: 1