I'm building a small web application which contains user types of User or Admin.
Within my users table, I have a boolean flag, is_admin
. I'm trying to design a query such that a web application user can perform an insert into a table if is_admin
is true.
Is there a clear way to write an insert query where a boolean value is true? Should I be using a procedure or is there a better way to handle this?
CodePudding user response:
You can check first if it is is_admin
from users table and then insert into another table.
IF EXISTS (SELECT * FROM users WHERE is_admin=1 )
INSERT INTO Table