I
I
Ilushka2014-04-14 19:57:13
SQL
Ilushka, 2014-04-14 19:57:13

How to create a checkbox on a condition in MS Access using SQL methods?

Hello!
There is the following table:
Client number (something like id) | Client's Product (Website, Business Card, Banner, TV) | Income | Flag (new field)
The essence is this: all uploads are line by line. One customer number can have several products. I need to make one more field in which one would be put down for a client who has a TV product and one would also be put down for every other product of this client (it is simply marked as with TV in each line)
And for the rest 0
Please tell me How can this be done in Access. There is a lot of data, Excel is not an option :)
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2014-04-14
@Ilushka

The first query is to fetch unique customer IDs that have product="TV" :

SELECT DISTINCT Таблица1.КлиентИД
FROM Таблица1
WHERE Таблица1.Продукт="ТВ";

The second request is to update the Flag field in the records whose ClientID is included in Request1 :
UPDATE Таблица1 SET Таблица1.Флажок = 1
WHERE КлиентИД IN (SELECT * FROM Запрос1);

Checked in 2007 - it works.
PS Collected into one - it also works (in Access it's not always with nested queries):
UPDATE Таблица1 SET Флажок = 1
WHERE (КлиентИД In (SELECT DISTINCT КлиентИД
FROM Таблица1
WHERE (Продукт="ТВ")));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question