insert into from multiple tables and with multiple conditions
Hi
I've been working on migrating some tables from an old forum software to a new one.
So I am matching up tables/colums etc. to move everything in one go.
I am concentrating on one table in the new forum software to start off, and to get all data into the new, I need to extract data from multiple tables from the old software.
Code:
insert into bzhv8_kunena_topics
(id,
first_post_userid,
first_post_guest_name,
subject,
first_post_time,
last_post_time,
last_post_id,
last_post_guest_name,
hits,
first_post_id,
posts,
ordering,
category_id,
first_post_id)
select A.id,
B.id,
A.poster,
A.subject,
A.posted,
A.last_post,
A.last_post_id,
A.last_poster,
A.num_views,
A.id,
A.num_replies,
A.sticky,
A.forum_id,
C.message
from
(SELECT * from jos_agora_topics where id = 2) A,
(select * from jos_agora_users ) B,
where B.username = A.Poster
The above works :-) I am using "where id = 2" just to limit the amount of rows while I am testing.
Now I want to expand the insert to include some more stuff which I need to get from other tables.
I first tried to insert this :
Code:
(SELECT * from jos_agora_posts where topic_id = 2 ) C
where C.id = A.id
Below the above.. but it fails miserably.
and I added the appropriate 2 lines in insert & select to add the new column matchup.
So what I need help with is... how do I expand my sql to include more?