SQL Statement

G

Guest

Let's see if I can explain my question as easy as possible...


I am trying to create Macro using SQL Statements. This is what I want to
happen:

I currently have three columns in a table: Store #, Region, and Location

EX. of data:

Store # Region Location

0001 0123 ABC
0002 0123 DEF
0003 4567 GHI
0005 0123 JKL
0006 0123 MNO
0007 4567 PQR


The relevant information I need is under the Store # and Region, I don't
need the Location information.

However, I would like to use the Location column to indicate something
different.

If Sore # equals 0001 and Region equals 0123, I want the field under
Location to change to 'Atlanta 1,' not ABC.

If Store # equals 0002 and Region equals 0123, I want the field under
location to change to 'Atlanta 1,' not DEF

If Store # equals 0005 and Region equals 0123, I want the field under
location to change to 'Atlanta B,' not JKL.



Basically, I am looking for an SQL Statement that will allow me to match up
two fields in a record and then change the third field. I understand I will
have to write an SQL statement for each combination I want to have changed.
It will save me time in the long run.

This is what I would want the table to look like after I run the Macro:

Store # Region Location

0001 0123 Atlanta 1
0002 0123 Atlanta 1
0003 4567 Columbus 3
0005 0123 Atlanta 2
0006 0123 Atlanta 1
0007 4567 Columbus 1



Thanks in advance if you can help!!!
 
G

Guest

Hi Bonnie,

If you are wanting to actually UPDATE the information, use an Update SQL
statement like this:

update TABLENAME set Location = 'Atlanta 1'
where [Store #] = '0001' and Region = '0123'

Hope this helps.

Damian.
 

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

Top