Ask a Question related to MySQL, Design and Development.
-
Ignoramus23298 #1
Select-And-Update in one statement?
On my site I often do
SELECT counter from counters where id = 10
UPDATE counter set counter = counter + 1
Can I somehow merge them into one statement?
Like (in C)
SELECT counter++ from counters where id = 10
can that be done?
i
Ignoramus23298 Guest
-
sql select case statement
Hi, Im trying to put together a sql select case statement for coldfusion - can anyone please check over my code and see if i am going along the... -
SP with Select statement
Hi, I'm trying to select fileds that are in the results of a SP. So I have the table "tblItem" itemID int Identity Key, itemName varchar... -
help with SELECT statement
"Aaron" <abroadway@ameritrust.com> wrote in message news:05a601c365df$b31a8d40$a401280a@phx.gbl... "SUM(ABS(action_date>= {" & start_date2 & "}... -
Update and Select Statement
Hi to all, I have VB application calling a SP. It works when: --return this to application SELECT * FROM tblVariance WHERE VarianceID =... -
SELECT statement
I have 3 tables: table countryPrice: productID countryId price 1 Italy 90 1 England ... -
Axel Schwenke #2
Re: Select-And-Update in one statement?
Ignoramus23298 <ignoramus23298@NOSPAM.23298.invalid> wrote:
You can do READ-MODIFY-WRITE in a single statement (and thus:>
> SELECT counter from counters where id = 10
> UPDATE counter set counter = counter + 1
>
> Can I somehow merge them into one statement?
free from race condition) like this:
UPDATE counters SET counter = (@x:= counter) + 1 WHERE id = 10
However you still need a second statement to read the (old)
value of the counter:
SELECT @x
In case you wonder what @x is - consult the manual
<http://dev.mysql.com/doc/refman/5.0/en/user-variables.html>
HTH, XL
--
Axel Schwenke, Senior Software Developer, MySQL AB
Online User Manual: [url]http://dev.mysql.com/doc/refman/5.0/en/[/url]
MySQL User Forums: [url]http://forums.mysql.com/[/url]
Axel Schwenke Guest



Reply With Quote

