SQL for Smarties | SQL Programming Style | Trees and Hierarchies in SQL | SQL Puzzles and Answers | Data and Databases

Tuesday, April 10, 2007

need help switching a boolean value

SQL Apprentice Question
what i want to acheieve is the following, in my table i have an "isactive"
field, i want to create a sql line something like

update tblProducts set isactive = NOT isactive where productID=123....but it
doesnt work.. is there any syntax that handles this in sql?

Celko Answers
>> in my table i have an "isactive" field [sic: fields and columns are TOTALLY different concepts!!!], I want to create a SQL line [sic: statement? that makes no sense!!] something like this: <<

Do you every read ISO Standards and know not to use "tbl" affixes?

UPDATE Products
SET isactive -- assembly lamnguage flag in SQL !!!
= NOT isactive
WHERE product_id = 123;

....but it doesn't work <<

DUH!! If you had bothered to read ANY SQL book before posting, you
would know we have no Boolean data types in SQL. If you had a better
education in math or RDBMS, you would know why.

Newsgroups are a bad place to get a basic education. We will give you
kludges to get rid of you because of your stupid questions, but they
will not make you a good programmer.

No comments: