January 26, 2009 at 1:39 pm
I have a two tables.
Table 1 temp_sales is filled with all the records from my transactional database
Table 2 temp2_sales is filled data data that has a product number greater than 0(zero).
I now want to insert into table 2 all the data from table 1 where the product code = 0 but the customer number does not exist in table 2.
I know this is simple stuff but I think the cold in the north is getting to ym head.
My Sql:
select temp_sales.* from temp_sales, temp2_sales
where temp_sales.product_number = 0
and temp_sales.customer_number <> tmp2_sales.customer_number
does anyone see what I am doing wrong?
January 26, 2009 at 2:01 pm
Something like:???
insert into temp2_sales
select * from temp_sales
where temp_sales.product_number = 0
and temp_sales.customer_number not in (customer_ID from temp2_sales)
-- You can't be late until you show up.
January 28, 2009 at 6:33 am
tosscrosby (1/26/2009)
Something like:???insert into temp2_sales
select * from temp_sales
where temp_sales.product_number = 0
and temp_sales.customer_number not in (SELECT customer_ID from temp2_sales)
Almost, you missed out a SELECT, see above
January 28, 2009 at 6:38 am
Thanks.
I can't belive I could not get that SQL. Soooooooo Simple.
THanks Again
January 28, 2009 at 7:36 am
Adam McArdle (1/28/2009)
tosscrosby (1/26/2009)
Something like:???insert into temp2_sales
select * from temp_sales
where temp_sales.product_number = 0
and temp_sales.customer_number not in (SELECT customer_ID from temp2_sales)
Almost, you missed out a SELECT, see above
Thanks for having my back!
-- You can't be late until you show up.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply