V
V
Verg1l2015-02-25 17:29:58
Java
Verg1l, 2015-02-25 17:29:58

How to pass a variable to the database knowing the id of the desired row?

I add the data to a DB, I receive id of the added line. You need to insert this ID into the desired cell knowing the ID of the line.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
Ytsu Ytsuevich, 2015-02-25
@Verg1l

id INT
name VARCHAR(50)

UPDATE SomeTable SET name = 'Petya'
WHERE id = 10

Instead of 10, your number.
If you need to add:
INSERT INTO SomeTable (name)
VALUES ('Vasya')
WHERE id = 11

https://ru.wikipedia.org/wiki/Update_ (SQL)
https://ru.wikipedia.org/wiki/Insert_ (SQL)

I
Ivan, 2015-02-25
@LiguidCool

SQL Insert/Update? What is the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question