Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

sql approach to allow web application user to insert based on permissions

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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 
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading