A
A
alihang2018-04-22 14:25:43
MySQL
alihang, 2018-04-22 14:25:43

How to change the values ​​of only one line in the database?

Hello, there is a table in which there are rows with a unique id and data that need to be changed (likes_count)
5adc704070375031932761.png
To change the data, I used the following query:

SELECT id FROM `users` WHERE `id` = '$rows ['id']'; UPDATE `users` SET `likes_count`= '2' WHERE 1

But it changes the data for all rows, and not for the id obtained from the rows array. With my efforts, I came to the conclusion that I need to write another request, but I just can’t figure out how to compose it ..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Sukhikh, 2018-04-22
@alihang

UPDATE `users` SET ``likes_count` = "Value to change to" WHERE `id` = id to change to

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question