coder
coder

Reputation: 13248

Adding a column from one table to another

I am currently using asp.net membership provider and it has several tables as shown below!

enter image description here

And in this there are two main tables where the info of user is stored such as username,password,email etc..

Now I have password column in Membership table.So I would like to include a copy of that in the users table.

So how can I do that?

Upvotes: 0

Views: 179

Answers (2)

Ben Thul
Ben Thul

Reputation: 32697

I'd advise against altering the schema as provided by MS at all. If you find yourself in a situation where you need to call support and they find out that you did that, they are within their right to not help.

Upvotes: 0

Christian Specht
Christian Specht

Reputation: 36431

Actually creating a "password" field in the Users table and copying the content of the Membership table is not a good idea, as already pointed out by HLGEM in his comment.

If you really want to query the Users table and get the password from the Membership table in the same query, why don't you just join the tables?

SELECT aspnet_Membership.Password, aspnet_Users.*
FROM aspnet_Membership 
INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId

If you need this query really often, you can create it as a view:

CREATE VIEW YourUserView AS
SELECT aspnet_Membership.Password, aspnet_Users.*
FROM aspnet_Membership 
INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId

Upvotes: 3

Related Questions