1

I created 9 columns each which hold either a 0 or a 1 integer. They exist so that users can toggle certain things on and off. I'd like to get rid of these 9 columns and instead use only one column where i can hold 9 0's and 1's for the 9 things my users will toggle. So say i have 000000000 and my user decides to toggle the first function, how would an update query for table accounts and column toggletimers look like which would change the value to 100000000 and so on for the 9 numbers?

2

1 Answer 1

1
  1. You normally should not merge multiple fields into one in database design (violation of "1NF")
  2. If you really want to, use the bitwise operations: update accounts set toggletimers = toggletimers | (1 << (9-1)) where ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.