Click here to Skip to main content
15,903,388 members
Home / Discussions / Database
   

Database

 
GeneralRe: Database table design Pin
scorp_scorp9-Jan-11 21:06
scorp_scorp9-Jan-11 21:06 
Questionerror in sql Pin
mandarapu3-Jan-11 21:14
mandarapu3-Jan-11 21:14 
AnswerRe: error in sql Pin
Bernhard Hiller3-Jan-11 23:14
Bernhard Hiller3-Jan-11 23:14 
AnswerRe: error in sql Pin
Hiren solanki3-Jan-11 23:28
Hiren solanki3-Jan-11 23:28 
QuestionIndex with two columns of table Pin
vanikanc3-Jan-11 4:05
vanikanc3-Jan-11 4:05 
AnswerRe: Index with two columns of table Pin
Corporal Agarn3-Jan-11 5:13
professionalCorporal Agarn3-Jan-11 5:13 
Questionlack of index in mysql document Pin
followait31-Dec-10 16:50
followait31-Dec-10 16:50 
QuestionJoin and Update statement using junction table and sql Pin
jboyd11130-Dec-10 10:19
jboyd11130-Dec-10 10:19 
Hi, I've searched and haven't found a relevant answer to this 'simple' problem.

I have 3 tables, one of which is a junction table between the other two:

Users
-----
UserId
UserName

Roles
-----
RoleId
RoleName

UserRoles
---------
UserRoleId
UserId
RoleId

There are FK relationships between UserRoles and the other 2 tables.

Problem statement:
What I want to do is update the user's RoleId in the UserRoles table if I only have the person's RoleName and UserName.

Here's what I'm starting with code-wise (MSSQL):

<br />
				update a<br />
				set a.RoleId  = ?? Set to what?<br />
				FROM UserRoles a<br />
				inner join Users b on a.UserId = b.UserId<br />
				inner join Roles c on a.RoleId=c.RoleId<br />
where c.RoleName= 'Administrator' AND b.UserName='someuser'<br />


Further information:
I'm trying to do this within an update method call within an ASP.NET GridView control. This information may be a bit more than what's needed but I thought I would mention it just in case it may offer a different solution.
Thanks for any assistance in advance.

---
Stan
AnswerRe: Join and Update statement using junction table and sql Pin
Luc Pattyn30-Dec-10 10:34
sitebuilderLuc Pattyn30-Dec-10 10:34 
GeneralRe: Join and Update statement using junction table and sql Pin
jboyd11130-Dec-10 16:06
jboyd11130-Dec-10 16:06 
AnswerRe: Join and Update statement using junction table and sql Pin
Luc Pattyn30-Dec-10 23:24
sitebuilderLuc Pattyn30-Dec-10 23:24 
GeneralRe: Join and Update statement using junction table and sql Pin
jboyd1113-Jan-11 8:50
jboyd1113-Jan-11 8:50 
AnswerRe: Join and Update statement using junction table and sql Pin
Jörgen Andersson3-Jan-11 23:36
professionalJörgen Andersson3-Jan-11 23:36 
GeneralRe: Join and Update statement using junction table and sql Pin
jboyd1115-Jan-11 11:13
jboyd1115-Jan-11 11:13 
Questionsp_databases dosn't return any value in Sql server 2008 express. Pin
prasadbuddhika29-Dec-10 23:43
prasadbuddhika29-Dec-10 23:43 
AnswerRe: sp_databases dosn't return any value in Sql server 2008 express. Pin
Simon_Whale30-Dec-10 0:35
Simon_Whale30-Dec-10 0:35 
GeneralRe: sp_databases dosn't return any value in Sql server 2008 express. Pin
prasadbuddhika30-Dec-10 0:42
prasadbuddhika30-Dec-10 0:42 
GeneralRe: sp_databases dosn't return any value in Sql server 2008 express. Pin
Simon_Whale30-Dec-10 0:44
Simon_Whale30-Dec-10 0:44 
GeneralRe: sp_databases dosn't return any value in Sql server 2008 express. Pin
prasadbuddhika30-Dec-10 1:13
prasadbuddhika30-Dec-10 1:13 
GeneralMessage Removed Pin
30-Dec-10 2:25
professionalCorporal Agarn30-Dec-10 2:25 
GeneralRe: sp_databases dosn't return any value in Sql server 2008 express. Pin
Simon_Whale30-Dec-10 2:44
Simon_Whale30-Dec-10 2:44 
GeneralRe: sp_databases dosn't return any value in Sql server 2008 express. Pin
Corporal Agarn30-Dec-10 2:45
professionalCorporal Agarn30-Dec-10 2:45 
GeneralRe: sp_databases dosn't return any value in Sql server 2008 express. Pin
Simon_Whale30-Dec-10 3:17
Simon_Whale30-Dec-10 3:17 
QuestionCan you tell how to Sort in Oracle DB? Pin
openboy201029-Dec-10 22:21
openboy201029-Dec-10 22:21 
AnswerRe: Can you tell how to Sort in Oracle DB? [modified] Pin
badprog30-Dec-10 3:46
badprog30-Dec-10 3:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.