PC Nerd Posted June 27, 2007 Share Posted June 27, 2007 hey i want to increment a database value by one..... can i do this with an embedded SELECT in my SQL, or would i have to have 2 different queries? Update table Set field= Select field2 from table2 where x=y, Where field=z? sorry if this SQL isnt very clear, hopefully it will be...... :-\ Link to comment https://forums.phpfreaks.com/topic/57393-embedded-sql/ Share on other sites More sharing options...
.Stealth Posted June 27, 2007 Share Posted June 27, 2007 Cant you use "AUTO_INCREMENT"? Link to comment https://forums.phpfreaks.com/topic/57393-embedded-sql/#findComment-283913 Share on other sites More sharing options...
PC Nerd Posted June 27, 2007 Author Share Posted June 27, 2007 no: im storing "lotto" numbere occurence. its a game for my maths class. every time a number is picked, i logg it int eh database, eg, increment it............ so theres only one record int eh table. so i really just want to have a way to increment one field, by one in the one SQL query thanks Link to comment https://forums.phpfreaks.com/topic/57393-embedded-sql/#findComment-283914 Share on other sites More sharing options...
sushant_d84 Posted June 27, 2007 Share Posted June 27, 2007 Yes...... U can Use the AUTO_INCREAMENT also u r query need to modify as below " UPDATE tablename SET filed= (select max(filed) from tablename) +1 WHERE filed = oldvalue " try out this and let me know is that working for u ? Regards Sushant Link to comment https://forums.phpfreaks.com/topic/57393-embedded-sql/#findComment-283918 Share on other sites More sharing options...
PC Nerd Posted June 27, 2007 Author Share Posted June 27, 2007 thanks, will do now Link to comment https://forums.phpfreaks.com/topic/57393-embedded-sql/#findComment-283919 Share on other sites More sharing options...
sushant_d84 Posted June 29, 2007 Share Posted June 29, 2007 Is That solved by My Method ? Link to comment https://forums.phpfreaks.com/topic/57393-embedded-sql/#findComment-285561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.