Filling a Column in Case Statement in reference to another column (1 Viewer)

Arlmachado

Registered User.
Local time
Today, 10:58
Joined
Mar 9, 2017
Messages
17
I am fairly new to SQL language and I am trying to do some work for Uni in Access. I have three columns: Bindugen, with values shown below, and then blank Columns Code and 33/SDGL:

Bindungen: 33,811, / 811,SDGL,33,/ 33,812,SDGL, / 812,SDGL,/ 811, (etc.)

My main column is Bindungen and I want to fill the others in relation to that one. Basically in the column 33/SDGL I tried to do the Update Case When Statement shown below. It obviously didn't work.

SELECT
FROM Codes;
UPDATE (Codes)
SET 33/SDGL ( CASE
WHEN Bindungen = "*," THEN Allein
WHEN Bindungen = "33,*," Or "*,33," THEN 33
WHEN Bindungen = "SDGL,*," Or "*,SDGL," THEN SDGL
ELSE Both
END);
My goal for the 33/SDGL column is that when Bindungen is: "," = Allein / ",33," Or "33,," = 33 / ",SDGL," Or "SDGL,*," = SDGL

and for the rest = BOTH

Could someone help me write this SQL code?

Also for the Code column, I would like it to find from Bindungen which code is there (eg: 811 or 812). Can someone point me in the right direction?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:58
Joined
Feb 19, 2013
Messages
16,553
there isn't a case option in Access sql. Instead use the switch function - something like

UPDATE (Codes)
SET 33/SDGL =switch(Bindungen = "*,",Allein,Bindungen = "33,*," Or Bindungen = "*,33,",33,Bindungen = "SDGL,*," Or Bindungen = "*,SDGL,",SDGL,true,Both)

I presume Bindungen, Allein and Both are all fields that exist in the Codes table. Also you should not start field names with numbers

I don't understand this comment

Also for the Code column, I would like it to find from Bindungen which code is there (eg: 811 or 812). Can someone point me in the right direction?
 

Users who are viewing this thread

Top Bottom