How to insert a inner join query in a table

Hi

I have this query:

SELECT tbhy_logdata_20120821.User, tbhy_logdata_20120821.UserName, tbhy_logdata_20120821.Desk, tbhy_logdata_20120821.Action, tbhy_logdata_20120821.Field, CONCAT(tbhy_logdata_20120821.Project,'<|1|>',tbhy_logdata_20120821.Desk,'<|1|>',tbhy_logdata_20120821.Action,'<|1|>',tbhy_logdata_20120821.Field) AS CON, tbasys_timeline_a.TimeLine, tbasys_timeline_a.Concatenate FROM tbhy_logdata_20120821 INNER JOIN tbasys_timeline_a ON Concat(tbhy_logdata_20120821.Project,'<|1|>',tbhy_logdata_20120821.Desk,'<|1|>',tbhy_logdata_20120821.Action,'<|1|>',tbhy_logdata_20120821.Field) =tbasys_timeline_a.Concatenate

And I have to insert this into a table that has 7 fields: User, UserName, Desk, Action, Field, Concat, TimeLine!

Thank you,
Qw MAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
simply do a INSERT:;

insert into yourtable ( User, UserName, Desk, Action, Field, Concat, TimeLine )

SELECT tbhy_logdata_20120821.User, tbhy_logdata_20120821.UserName, tbhy_logdata_20120821.Desk, tbhy_logdata_20120821.Action, tbhy_logdata_20120821.Field, CONCAT(tbhy_logdata_20120821.Project,'<|1|>',tbhy_logdata_20120821.Desk,'<|1|>',tbhy_logdata_20120821.Action,'<|1|>',tbhy_logdata_20120821.Field) AS CON, tbasys_timeline_a.TimeLine, tbasys_timeline_a.Concatenate FROM tbhy_logdata_20120821 INNER JOIN tbasys_timeline_a ON Concat(tbhy_logdata_20120821.Project,'<|1|>',tbhy_logdata_20120821.Desk,'<|1|>',tbhy_logdata_20120821.Action,'<|1|>',tbhy_logdata_20120821.Field) =tbasys_timeline_a.Concatenate

Open in new window

0
 
Anuradha GoliSystems Development / Support SpecialistCommented:
Insert into <newtable>(<field1>,<field2>,.............,<field7>)
(
select statement.....................
);

Open in new window

0
 
Qw MAuthor Commented:
@angelIII: I get an error: Column count dosen't match value count at row 1!

Thank you,
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
well, your SELECT indeed returns 8 columns, so you need to remove the one you don't want be inserted to the final table
0
 
Qw MAuthor Commented:
@angelIII: Got it! I missed 1 column.

Thank you for your support!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.