ms-access


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".

Related Links

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?

Categories

HOME
cakephp
react-virtualized
bpmn
youtube-api-v3
angular-ui-bootstrap
ojdbc
webrequest
contact
kibana-4
tomcat6
kentor-authservices
wheelnav.js
postgres-xl
resize
caml
lombok
clojurescript
facebook-page
crystal-reports-2008
lldb
zapier
functional-testing
sox
core-text
captiveportal
hammerspoon
icloud-api
info.plist
greendao
buck
wtx
webkitspeechrecognition
objectanimator
c++-amp
google-cloud-nl
newline
gsmcomm
bpel
madlib
binary-data
code-contracts
commit
openoffice.org
xmlreader
overriding
serve
uft-api
elasticsearch-plugin
dism
sas-jmp
appcompat
prolog-setof
sage-one
sqlclient
crypt
r-forge
vtigercrm
pintos
azure-sdk
radtreelist
multi-level
skobbler-maps
clang-static-analyzer
skype4py
master-slave
pickadate
dlna
ford-fulkerson
hsv
prerequisites
key-management
dereference
javax.mail
fscommand
nstableviewcell
network-interface
java.util.concurrent
centos5
ms-project-server-2010
xamlparseexception
http-unit
android-hardware
wsdl-2.0
distutils
frameset
getmessage
eclipse-templates
cinema-4d
pyinotify
subviews
wise
anti-piracy
sector
mediarss
msdev

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App