I got problem here. im updating name where B has the biggest value.
so the results are
B | name
---|------
1 |
2 |
3 | YES
but when column B changes value the problem is column name with row value 3 still has a value.
B | name
---|------
1 |
4 | YES
3 | YES
the results should be.
B | name
---|------
1 |
4 | YES
3 |
if
B | name
---|------
0 |
0 |
0 |
then
B | name
---|------
0 |
0 |
0 |
if,
B | name
---|------
4 |
4 |
2 |
then
B | name
---|------
4 | YES
4 | YES
2 |
this is what i want.
im only using this simple code.
$sql3 = "UPDATE products SET name='YES' ORDER BY B DESC";
解决方案
I think you want to update the row in the the table where column B is the highest value? You definitely need a "WHERE" clause, but you also need to know the highest value in that column. Why don't you query the database first to retrieve the highest value from column B?
$maxvalue = "SELECT `B` FROM products ORDER BY `B` DESC LIMIT 1"
and then insert into the database WHERE the column B equals this value?
"UPDATE products SET name='YES' WHERE B = $maxvalue"
This is not complete code, just conceptual. I will clean it up and edit this answer...