Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need help with update statement

Author  Topic 

Lenjaku
Starting Member

13 Posts

Posted - 2012-07-19 : 08:30:09
This is my select statement:

SELECT Users.User_ID,[User_password],[User_email],[User_display_name],[Name_of_type] FROM [Users] INNER JOIN [UserType] ON Users.User_type=UserType.User_ID

When I add values to update I enter a string (since it is a string type value but it is a field from another table which I don't want to change I just want to edit the value of the current table based on it)
Eventually I want an int to be in this table.

These are the tables:

Users:
User_ID(string),User_password(string),User_email(string),*User_type(int),User_display_name(string)

UserType:
*User_ID(int),Name_of_type(string),Description(strng)

*please notice that Users.User_ID(int) is UserType.User_ID(int).
And UserType.Name_of_type(string) is what I actually enter.
And please notice that
Users.User_ID(string) is NOT UserType.User_ID(int)
I know the fields are the same and it is by mistake it is rather confusing I may change it.

xhostx
Constraint Violating Yak Guru

277 Posts

Posted - 2012-07-19 : 08:40:28
*please notice that Users.User_ID(int) is UserType.User_ID(int).
And UserType.Name_of_type(string) is what I actually enter.
And please notice that
Users.User_ID(string) is NOT UserType.User_ID(int)

aren't they the same??


--------------------------
Get rich or die trying
--------------------------
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-07-19 : 08:57:26
Your sample select is already showing us how to join these two tables.
Instead of confusing us with the rest of your post you should give us the information: what do you want to be updated.

Best way to do this:
sample data in relation to the above given table structure AND
the wanted result


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Lenjaku
Starting Member

13 Posts

Posted - 2012-07-19 : 09:00:24
quote:
Originally posted by xhostx

*please notice that Users.User_ID(int) is UserType.User_ID(int).
And UserType.Name_of_type(string) is what I actually enter.
And please notice that
Users.User_ID(string) is NOT UserType.User_ID(int)

aren't they the same??


--------------------------
Get rich or die trying
--------------------------



Yea my bad could b nice if the site had edit option >.<

This is what I meant
Users.User_type(int) is UserType.User_ID(int)
Users.UserID does not exist in the usertype table there is no logic in doing that.
Users is users table and usertype table is to expend the meaning of the user_type field in users.
Go to Top of Page

Lenjaku
Starting Member

13 Posts

Posted - 2012-07-19 : 09:03:57
Anyway the idea is
a.num1=b.num2
But b.string is desplayed instead.

I am dealign with a gridview here that stupidly enters
b.string=value and tries to put it in a or I dunno what it wants to do, it doesn;t work.
When I tried to remove that field it worked so I figured this is the probelm and seek to correct the update statement.

I know it is stupid to enter values.
I;d like a drop box or soemthing but I lack the knowlage to add it.
Go to Top of Page
   

- Advertisement -