วันพุธที่ 30 มีนาคม พ.ศ. 2554

MySQL Set Variable

require scenario : i'am need to run number invoice

#--style runno ;
set @rn=(select runno from tablerunno where (theruntable='x0x' and therunfield='xxx'));
#--use rn to invoice display value
select @rn as inv;
#--update runno back to field runno
update tablerunno set runno = (select @rn)+1 where (theruntable='x0x' and therunfield='xxx');