I had a DB column named 'mai_confirmed' (confirmed for mailing), but I needed a column with the value for 'needsConfirmation' for a mailing component.
Or, to say it codish: needsConfirmation = not mai_confirmed
I tried SELECT !mai_confirmed AS needsConfirmation, and also SELECT (NOT mai_confirmed) AS needsConfirmation, but those didn't work.
The trick is:
SELECT mai_confirmed + 1 % 2 AS needsConfirmation
Even though the resulting value is not a bit field anymore, it does return either NULL, 1, or 0. Which was fine enough for me ;-)
| Viewed 323 times






#1 by Frank - February 10, 2010 at 7:46 PM
#2 by mehdi Saghari - February 19, 2010 at 7:34 PM
#3 by Jason Rushton - February 25, 2010 at 7:30 PM
#4 by Mehdi Saghari - February 25, 2010 at 8:09 PM
#5 by Paul Klinkenberg - February 27, 2010 at 11:21 PM
#6 by phil - June 30, 2010 at 3:20 PM
#7 by phil - June 30, 2010 at 3:25 PM
#8 by Mehdi Saghari - June 30, 2010 at 5:04 PM