My table has 5 columns. I would like to
UPDATE Column5='TEACHER' IF Column2='Y'
AND
UPDATE Column5='STUDENT' IF Column3='Y'
Can I do this in a single statement?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can probably use a
CASEstatement. My guess is that you want something like thisI’m guessing that you don’t want to update rows where neither condition is met. If you want to update every row, you’ll want to remove the
WHEREclause and you may want to adjust what the default value is (theELSEin theCASE) for rows where neither condition is met.