SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need help with update statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Lenjaku
Starting Member

13 Posts

Posted - 07/19/2012 :  08:30:09  Show Profile  Reply with Quote
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

USA
261 Posts

Posted - 07/19/2012 :  08:40:28  Show Profile  Reply with Quote
*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
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 07/19/2012 :  08:57:26  Show Profile  Visit webfred's Homepage  Reply with Quote
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 - 07/19/2012 :  09:00:24  Show Profile  Reply with Quote
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 - 07/19/2012 :  09:03:57  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000