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
 Help with Update query

Author  Topic 

sinscythex
Starting Member

2 Posts

Posted - 2011-03-24 : 02:48:44
I have two tables - Book and Transaction. What I'm trying to do is update a column on transactions named Book_Name. The value will come from the table Book, which houses a column also named Book_Name. Both tables have a column named Book_Id. I will have the user enter a value called Book ID on a textbox. The query should first look a match between the value entered by the user, and the column Book_Id from table Books. If there is a match, it should get the Book_Name from Books and pass it on to Book_Name of transactions, on the latest row.
I'm trying to use this code but to no avail

Update Transactions Set Book_Name= (Select Book_Name from Bbooks where Book_Id=@h) Where Trans_Id = (Select Max(Trans_Id) from Transactions)


@h = value of the textbox ( I'm using VB.net for this). Thanks for any idea.

Ameli
Starting Member

1 Post

Posted - 2011-03-24 : 04:46:16
I'm sorry, sinscythex, for posting in a wrong place! :) I just did not find any close topic to my question! I don't understand much of the things you discuss here, as I'm not so advanced in computer! I have problems with my internet speed, and i need a way to check my speed, I have found http://chinaspeedtest.net but i don't understand anything! Can you, please, help me with a piece of advice how to check my speed and what can i actually do if it works tooooo slowly?????
Thanks in advance! :)
Go to Top of Page

sinscythex
Starting Member

2 Posts

Posted - 2011-03-24 : 09:48:00
Sorry mate but I have no knowledge with that speed stuffs.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-03-25 : 15:56:34
quote:
Originally posted by sinscythex

I have two tables - Book and Transaction. What I'm trying to do is update a column on transactions named Book_Name. The value will come from the table Book, which houses a column also named Book_Name. Both tables have a column named Book_Id. I will have the user enter a value called Book ID on a textbox. The query should first look a match between the value entered by the user, and the column Book_Id from table Books. If there is a match, it should get the Book_Name from Books and pass it on to Book_Name of transactions, on the latest row.
I'm trying to use this code but to no avail

Update Transactions Set Book_Name= (Select Book_Name from Bbooks where Book_Id=@h) Where Trans_Id = (Select Max(Trans_Id) from Transactions)


@h = value of the textbox ( I'm using VB.net for this). Thanks for any idea.




Can you give more informations?
Are there error messages?
What happens when you run the posted statement?
...


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

- Advertisement -