Filling a column with Case When Statement in reference to another column
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?
MS Access does not use the CASE statement. You need to write a SWITCH statement instead, like this: SWITCH(Bindungen = "*,", Allein, Bindungen = "33,*,", 33, Bindungen = "*,33,", 33, Bindungen = "SDGL,*,", SDGL, Bindungen = "*,SDGL,", SDGL, BOTH) Also note that in this situation, Allein, SDGL, and BOTH must ALL be fields that you are selecting from. If you just want the text instead of a field value, wrap those words in "double quotes".
Infinitely looping through a recordset in VBA
Issue with the TOP 1 query
Calculating days between dates and parameters in MS Access
Alter MS Access Report output after its loaded
Is it possible to write this VBA code any better?
MS Access: Update a Linked List Box
How can I check if an instance of a Access 2010 form is still open?
How to debug a docmd.transferdatabase statement that does not work (no compiler error, simply does not xfer the data)
How to set initial selections of controls in a MS access report on its load?
Access 2000 Timeouts on bound recordset
Query to a Meaningful Report
MS Access “duplicate values” error, but I don't know why
Generate uml from vba
Is it possible to change Msysobjects in ms access
How can I make MS-Access choose a different/the right execution plan for my query
Access 2007 Reports - How to 'unfix' fields?