Update Query

  • Thread starter Thread starter Bryan
  • Start date Start date
B

Bryan

Hello All,

I need some help writing a query that will help me do the following.


Column to be use
1. Job Code
2. HR Location
3. Sub Group

If the job code begin with “EA†and the HR Location is RSF or US Main assign
Remote to that record in the Sub Group Column for everything else with a job
code that begin with “EA†assign Local

Please let me know the best way I will be able to accomplish this task.

Thank you,

Bryan
 
I'm not sure how to do that in one query. I usually use the Query builder
grid to build my queries and I don't see a way to update to one value in one
case and another vlaue in other cases, though there may be way to do it. My
suggestion would be to run 2 queries, one for the first case and one for the
2nd. Query 1 would be:

UPDATE tblX SET SubGroup = "Remote"
WHERE JobCode="EA" AND HRLocation IN ("RSF", "US MAIN");

Query 2 would be:

UPDATE tblX SET SubGroup = "Local"
WHERE JobCode="EA" AND HRLocation NOT IN ("RSF", "US MAIN");

I don't know if Access allows multiple SET/WHERE combinations in an SQL
UPDATE statement. If it does then you could try:

UPDATE tblX (SET SubGroup = "Remote"
WHERE JobCode="EA" AND HRLocation IN ("RSF", "US MAIN"))
(SET SubGroup = "Local"
WHERE JobCode="EA" AND HRLocation NOT IN ("RSF", "US MAIN"));
 
Back
Top