PoKeMoNG0 PoKeMoNG0 - 5 months ago 46
MySQL Question

UPDATE particular row in MYSQL using a row number

How to update a particular row from MYSQL DB when v r given a row number liek update username at row =5 , n nothing else is given , v dont want 2 use the WHERE Clause , all v know is row number

so how ??

UPDATE users set status=7 limit 5,1; // this is not working error in sql syntax

want 2 update 6th row

users=table name

same what will b the syntax for delete statement for the same operation ?


Read this post: Select specific row from mysql table

Now once u have selected a row,find a column whose data is unique say id or username ,email ,anything that is unique for a row. Lets say username is unique for ur table

Then do this

SELECT username FROM customer LIMIT 5,1;

Store it in a variable if u r using java/php/etc. now say u stored in variable var. then using this run another sql command

update users set status=7 where username=var ; 

//var is the varible name that u assigned value to.