0

I need to update a value in table with value in other table

String sql6="UPDATE project.wish_list SET project.wish_list.quantity= project.book.quantity";

But don't work why?

thank you

2
  • 1
    In human language, what you are saying is : set the wish list quantity to some value of book quantity, but I'm not going to tell you from which book. Why do you think he is unable to do that ? Commented Nov 28, 2014 at 14:32
  • @tvCa Real. I forgot to put in the isbn condition XD Commented Nov 28, 2014 at 16:12

3 Answers 3

2

You have to join the tables:

sql6="UPDATE project.wish_list join project.book on <condition> SET project.wish_lista.quantity= project.book.quantity";
Sign up to request clarification or add additional context in comments.

2 Comments

error ora-00971 missing set keyword: i tried sql6="UPDATE project.wish_list join project.book on project.book.isbn = project.wish_list.isbn SET project.wish_list.quantity= project.book.quantity";
@neo999 Can you try this: UPDATE project.wish_list SET project.wish_lista.quantity= (SELECT project.book.quantity FROM project.book WHERE project.book.isbn = project.wish_list.isbn)
2

First of all you have a syntax error:

UPDATE project.wish_list SET project.wish_lista.quantity= project.book.quantity

The "a" in whish_list -> "project.wish_lista.quantity"... it should be:

UPDATE project.wish_list SET project.wish_list.quantity= project.book.quantity

1 Comment

yes I know, It's typo error when i write post, sorry
2
Update wish_list set wish_list.quantity= book.quantity from wish_list as wish_list     

inner join book as book on wish_list.ID=book .ID

2 Comments

"on wish_list.ID" What is ID? (I have ISBN in book table and book wish list) thanks
ID is Primary Key For wish_list and Foreign Key for book or vice versa

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.