Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update with distinct

Status
Not open for further replies.

ronwmon

Programmer
Jul 13, 2007
97
US
I have a database with multiple tables. One table titled netbilling that contains (among others) the following fields:

ItemNum
ItemDesc
SubsChgs

I have another table titled billcode, I want to update the billcode table with data from the netbilling table. I want all of the fields above but I want to limit the update to distinct ItemNum. ItemDesc and Subschgs will also be distinct as every instance of ItemNum has the same ItemDesc and SubsChgs.

Any help is appreciated.

Ron--
 
Hi,

If your last statement is true, then you do not need to add ItemDesc and SubsChgs to this table nor should you, as this defies a principle of normalization.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I don't disagree.

This simple code doesn't work. Do you see the error?

Update BillCode SET BillCode.ItemNum = [netbilling].[ItemNum]
where (select distinct netbilling.itemnum from netbilling);
 
Maybe:

UPDATE BillCode
SET ItemNum = [netbilling].[ItemNum]
WHERE [blue]ItemNum IN [/blue](select distinct netbilling.itemnum from netbilling);

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
When I run this I get a dialog box titled Enter Parameter Value with netbilling.ItemNum.

Ron--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top