How to selectively insert data in fields

W

Wind54Surfer

Hi all,

I have a table "tblBills" with fields "orderID", "supplier", "suppliername"

and another table "tblInstSales" with fields "orderID", "installername",
"salesrepname"

How can I update the field "suppliername" based on what exists in field
"supplier"

Example: if in field "supplier" entry is "Installer" then use data from
field "installername" and if it is "Salesrep" then use data from
"salesrepname"

I am a newbie with limited query knowledge and appreciate any help.

Thanks in advance,
Emilio
 
S

Stefan Hoffmann

hi Emilio,
I have a table "tblBills" with fields "orderID", "supplier", "suppliername"
and another table "tblInstSales" with fields "orderID", "installername",
"salesrepname"
You normally don't need an UPDATE query, this SELECT does the lookup on
the fly:

SELECT *,
Iif(B.supplier = "Installer",
S.installername,
S.Salesrep) AS suppliername
FROM tblBills B
LEFT JOIN tblInstSales S
How can I update the field "suppliername" based on what exists in field
"supplier"
If you really need to update your table, use the SELECT from above and
make an UPDATE query withit in the query designer.


mfG
--> stefan <--
 
W

Wind54Surfer

Thanks Stefan for your help

Emilio

Stefan Hoffmann said:
hi Emilio,

You normally don't need an UPDATE query, this SELECT does the lookup on
the fly:

SELECT *,
Iif(B.supplier = "Installer",
S.installername,
S.Salesrep) AS suppliername
FROM tblBills B
LEFT JOIN tblInstSales S

If you really need to update your table, use the SELECT from above and
make an UPDATE query withit in the query designer.


mfG
--> stefan <--
 

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