Jump to content

embedded SQL


PC Nerd

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.