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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validating value prior to running update query 2

Status
Not open for further replies.

gwoman

Programmer
Joined
Nov 16, 2004
Messages
199
Location
US
Hello ...

I have been trying to create an update query to no avail ...

I have two tables... Status_table that joins to DQStatus_table ...
Status_table.api_nbr = DQStatus_table.state_api_nbr ...

I am trying to create an update query that will update Status_table.Status with DQStatus.state_desc where these two columns do not match (the columns are both string data types)...

If anyone has any ideas ... I would greatly appreciate it ...thanks!

Regards ...

gwoman

 
Why not just update the column regardless?

What I mean is if they match they'll not change but if they differ then you can change it?

While I understand generally a blanket update isn't a great idea (and I wouldn't normally recommend it) but I can't see why it wouldn't work here.

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
UPDATE Status_table INNER JOIN DQStatus_table ON Status_table.api_nbr = DQStatus_table.state_api_nbr
SET Status_table.Status = DQStatus.state_desc
WHERE DQStatus.state_desc <> Status_table.Status

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
HarleyQuinn ... Thanks ... I originally started with a blanket update query and it worked ... I was just trying to add some type of validation ... thanks...

PHV ... thanks will try it ....

Have a good one ...

gwoman
 
PHV ... right on ... works like a charm ... thanks!

g
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top