I am still very new to sql. I am having troubles updating one table. I am sending information from a web application into Microsoft SQL 2008 database. I have a table called EmployeePermissions that has employee ID and Permission ID. The Permission ID links this table to the Permissions table where different permissions are located and given a true or false value. If I am sending SQL the employee ID and the true or false values of the specific permissions, how do I update the Permissions table by sending the information through the EmployeePermissions table? Hopefully the diagram below can help explain a little better. Thanks!
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
OK, so I'm not going to comment on the table design as I assume that this is just part of the tables.
To do the update that you are looking for there's a couple of options.
You can get the Permission ID and put it into a variable, then use that against the permission table.
Or you can do it all with a join in your update statement.
In either case you'll want to properly parameterize the query in your application layer to prevent against SQL Injection.