Welcome to WebmasterWorld Guest from 54.224.230.193

Forum Moderators: open

Message Too Old, No Replies

Join SELECT an UPDATE?

     
7:02 pm on Nov 2, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 22, 2004
posts: 113
votes: 0


My site has a simple counter. there are two queries that run back to back. Is there any way to join these into one query? Even if it just reduced the number of database connections, this page gets loaded a lot, any little optimization will be magnified a lot.

1)
UPDATE `counter` SET main_counter = main_counter + 1


2)
SELECT `main_counter` FROM `counter`
8:55 pm on Nov 2, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 15, 2003
posts:2606
votes: 0


You can do it in a transaction...

the syntax depends on what db/version you are using.

Check the user guide of your db for TRANSACTION