This is my sql query. In flag(00000) each bit position has a different specification, for example. change 4th bit position to 1 when user is inactive . Here the flag is the varchar (String) data type.
$sql="select flag from user where id =1"
I got
flag=10001 #it may be flag="00001" or flag="00101"
I want to update the second bit of this flag to 1.
$sql="update user set flag='-1---' where id=1" #it may be flag='11001' or flag='01001' or flag='01110'
Actually, I want to update the second bit of this flag to 1, but without updating, like flag = '11001'.I want to do something like this.
$sql="update user set flag='--change(flag,2bit,to1)--' where id =1" #this is wrong
What can I do for this using just one SQL query? Is it possible?
source share