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".
Does MS Access Runtime 2010 works well on system with previous version of Access/Office installed?
“Too many indexes on table” error when creating relationships in Microsoft Access 2010
Display related fields from another table on a Microsoft Access form
How to pass values from client side html to server side in classic asp or vbscript?
Access Report ignores DISTINCROW in query
checking whether field in table has space or comma - MS-Access
Forms and Subforms in Access 2003
EasyPHP connecting to MS Access
Access 2010 Runtime question
Access Input textbox on Data Access page with only select enabled to allow filter by searchs
Microsoft Access Query through VBA gets repeated?
What sort of functionality can I expect from exporting a Microsoft Access 2007 Database to a WSS 3.0 site?
query muliple fields with multiple values
Force OpenCurrentDatabase to use Access 2003
ACCESS/VBA: How to create a ON/OFF type switch to allow record modification on a form?
dsn for ms access 2003 in windows 7