updating one table with info from another one?

R

Rudi Ahlers

How is this done?

Cause update comments set subscriber='Y' where comments.supplier =
company.company_name doesn't work

Yet, select comments.subscriber, comments.supplier, company.company_name
where comments.supplier = company.company_name does work....

--

Kind Regards
Rudi Ahlers
+27 (82) 926 1689

For as he thinks in his heart, so he is. ... (Proverbs 23:7)
 
M

Marina

That is because you are updating the 'comments' table, but referencing a
column in the 'company' table. So that SQL statement effectively makes no
sense.

If you are trying to update the table where the supplier exists as a row in
the company table, you could do something like:
update comments set subscriber='Y' where supplier in (select company_name
from company)
 
R

Rudi Ahlers

Thanx for the example, although it doesn't work. I tried to run it in
MSSQL Enterprise Manager, on MSSQL 2000 and I got an error saying:
Invalid object name 'company_scores'

Sorry the table name is actually company_scores, and not company like I
said in my first post.

when I run select
comments.supplier,comments.subscriber,company_scores.company_name from
company_scores,comment where company_scores.company_name =
comments.supplier, it does return those rows though
 
R

Rudi Ahlers

Thanx for the example, although it doesn't work. I tried to run it in
MSSQL Enterprise Manager, on MSSQL 2000 and I got an error saying:
Invalid object name 'company_scores'

Sorry the table name is actually company_scores, and not company like I
said in my first post.

when I run select
comments.supplier,comments.subscriber,company_scores.company_name from
company_scores,comment where company_scores.company_name =
comments.supplier, it does return those rows though
 
M

Marina

I've run queries similar to this just fine. Sounds like you have a syntax
error or something.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

table joins - 3 tables 5
URL showing username and password....? Please help 1
setting up worldpay 1
Worldpay 3
a trigger to update frames? 4
Adding a column to a remote DB 4
global.asa? 3
extending sessions 2

Top