SQLTeam.com | Weblogs | Forums

Join error and need help with formula

We need to insert 2 text fields and 2 fields from another table. When I mix the text and fields I always get an error so what is the best way to do this? We can clear the table before we insert data if needed but prefer not to.

We need to import as below and we need it to repeat 5 times on inv.i_id (Col1) for data 2 through 6:
text 1, Col1, text 2, Col2
text 1, Col1, text 3, Col2
text 1, Col1, text 4, Col3
text 1, Col1, text 5, Col3
text 1, Col1, text 6, Col3

Insert into TBL1 ("type","key", T_N, T_V)
SELECT '22', inv.i_id, 'Met', inv.l_d
LEFT JOIN inv ON inv.i_id = TBL1."key"

We are getting an error on the join. I am guessing from the key being used as the col name but it is the only col we can join on.
thank you.

You don't need a join at all, since you never use a column from the INVENTOR table:

Insert into TBL1 (“type”,“key”, T_N, T_V)
SELECT ‘22’, inv.i_id, ‘Met’, inv.i_d
FROM inv

That was my mistake. We are taking item_id, long_description and item_desc from inventor.

Insert into TABLE1 ("type","key", TAG_NAME, TAG_VALUE)
Values ('22', item_id, 'MetaKeywords', item_desc),
('22', item_id, 'MetaTitle', item_desc),
('22', item_id, 'DescriptionHeader', long_description),
('22', item_id, 'Description', long_description),
('22', item_id, 'MetaDescription', long_description)
SELECT item_id, item_desc, long_description
left JOIN Table1 ON "key" = item_id