I have a table in which following are the columns and their data-types
id=>AI,PK,int(11)
param_id=>varchar(45)
type=>varchar(45)
stationname=>varchar(45)
param=>varchar(45)
now when i insert a row in database:(database is MySQL, programming language c#)
insert into param_reference (Param_Id,Type,StationName,Param) values ('Res','" + Type + "','" + damName + "','maxQ')"
The row in table is like:
'1', 'Res', 'Reservoirs', 'B', 'maxQ'
param_id must be like 'Res1' where 1 is the auto-generated id. But when we insert this row we can't insert 'Res1' coz id is unknown and we get only after insertion. I did try as soon as after insertion of this above row
select id from param_reference where Type='" + Type + "',StationName='" + damName + "',Param='maxQ',Param_id='Res'
but it always returns null, it does not return the id. How can i solve this ? How can I get the id as soon as it is inserted. Also it should be the last id inserted coz there can be many rows like:
'1', 'Res', 'Reservoirs', 'B', 'maxQ'
'2', 'Res', 'Reservoirs', 'B', 'maxQ'
'3', 'Res', 'Reservoirs', 'B', 'maxQ'
'4', 'Res', 'Reservoirs', 'B', 'maxQ'
but Res will be having the id part too..
so i actually want to update 'Res' as 'Res2' as soon as second row is inserted.