관리 메뉴

Enjoy what you do!

mysql 행번호 붙이기, 행번호로 삭제, rownum 본문

컴공 여러가지/데이터베이스db,mysql

mysql 행번호 붙이기, 행번호로 삭제, rownum

쵸코맛 비비빅 2018. 2. 13. 10:53

set @rownum:=0;          //변수 선언해주고


select 

@rownum:=@rownum+1 as a, name    //변수에 1씩 더해가며 컬럼 만들어 select해준다.

from table;



이 삭제할때는 @rownum은 변수이니 이걸로 접근하면 안되고 as a 로 선언한 a로 접근하면 된다.

Comments