473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Select ... For update


Hello.

I want to update a row in a table with som data from another row.
Someting like this:

update $table set next = (select next from $table where id =" . $id[$i]
.. ") where id = (select next from $table where id =" . $id[$i] . ")

After searching mysql.com, I found out that I cut use someting called
select ... for update.
But how do you use it???

Rune Madsen
Jul 19 '05 #1
6 7476
BDR
What's wrong with simply selecting the data, and then updating the row
you want to change? (2 statements). Or, I guess you're working from the
command line?

Rune Madsen wrote:

Hello.

I want to update a row in a table with som data from another row.
Someting like this:

update $table set next = (select next from $table where id =" .
$id[$i] . ") where id = (select next from $table where id =" . $id[$i]
. ")

After searching mysql.com, I found out that I cut use someting called
select ... for update.
But how do you use it???

Rune Madsen


Jul 19 '05 #2
BDR
What's wrong with simply selecting the data, and then updating the row
you want to change? (2 statements). Or, I guess you're working from the
command line?

Rune Madsen wrote:

Hello.

I want to update a row in a table with som data from another row.
Someting like this:

update $table set next = (select next from $table where id =" .
$id[$i] . ") where id = (select next from $table where id =" . $id[$i]
. ")

After searching mysql.com, I found out that I cut use someting called
select ... for update.
But how do you use it???

Rune Madsen


Jul 19 '05 #3
On Sat, 18 Oct 2003 21:57:11 -0400, BDR <jo*@noemail.com> wrote:
What's wrong with simply selecting the data, and then updating the row
you want to change? (2 statements). Or, I guess you're working from the
command line?

I am working in php, but i want to avoid using more than one query if it
is posible.

Rune Madsen

Jul 19 '05 #4
On Sat, 18 Oct 2003 21:57:11 -0400, BDR <jo*@noemail.com> wrote:
What's wrong with simply selecting the data, and then updating the row
you want to change? (2 statements). Or, I guess you're working from the
command line?

I am working in php, but i want to avoid using more than one query if it
is posible.

Rune Madsen

Jul 19 '05 #5
BDR
I only say this from a standpoint of business practicality:

Sometimes,
1. It's just better to quickly write the new code, or,
2. Make a small change the db

and get it done in an hour (saving $$$ in time and trouble) than to

1. Lament for 2-3 days over a single complex query that's too difficult
to get to work, or,
2. Write a monster page of code to accomodate a database format, when a
single addition of a new table field and adding another query or two
will do the same thing without all the code overhead.

It's a balancing act, but one that needs to be evaluated constantly in
development.

Best of luck.

Rune Madsen wrote:
On Sat, 18 Oct 2003 21:57:11 -0400, BDR <jo*@noemail.com> wrote:
What's wrong with simply selecting the data, and then updating the row
you want to change? (2 statements). Or, I guess you're working from
the command line?

I am working in php, but i want to avoid using more than one query if
it is posible.

Rune Madsen


Jul 19 '05 #6
BDR
I only say this from a standpoint of business practicality:

Sometimes,
1. It's just better to quickly write the new code, or,
2. Make a small change the db

and get it done in an hour (saving $$$ in time and trouble) than to

1. Lament for 2-3 days over a single complex query that's too difficult
to get to work, or,
2. Write a monster page of code to accomodate a database format, when a
single addition of a new table field and adding another query or two
will do the same thing without all the code overhead.

It's a balancing act, but one that needs to be evaluated constantly in
development.

Best of luck.

Rune Madsen wrote:
On Sat, 18 Oct 2003 21:57:11 -0400, BDR <jo*@noemail.com> wrote:
What's wrong with simply selecting the data, and then updating the row
you want to change? (2 statements). Or, I guess you're working from
the command line?

I am working in php, but i want to avoid using more than one query if
it is posible.

Rune Madsen


Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Arthur | last post by:
Hey Everyone, Is this an Oracle bug? Here is my cursor statement: CURSOR tax_portal_cursor IS SELECT * FROM web_payment@remotedb WHERE caps_code IN ( SELECT * FROM TABLE(CAST(l_caps_codes...
5
by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN'...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
4
by: 001 | last post by:
Hello, The select statement needs only 1 second to complete the query. But the update statement spends 30 minutes. Why? SELECT STATEMENT: declare @IDate smalldatetime select @IDate=col001...
1
by: Grant McLean | last post by:
Hi First a simple question ... I have a table "access_log" that has foreign keys "app_id" and "app_user_id" that reference the "application_type" and "app_user" tables. When I insert into...
11
by: pmarisole | last post by:
I am trying to use the vbscript "split" function on a multi-select field. I am trying to do a mass update of several records at a time. I am getting an error and I'm not sure what to do. Here is...
4
by: pike | last post by:
DB2 UDB 8.1 FP7 We are getting intermittent deadlocks (911 RC 2) even when U row-lock has been secured. The transaction is as follows: 1) Select current application number value from table....
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
5
by: parwal.sandeep | last post by:
Hello grp! i'm using INNODB tables which are using frequently . if i fire a SELECT query which fetch major part of table it usually take 10-20 seconds to complete. in mean time if any UPDATE...
3
by: eholz1 | last post by:
Hello PHP programmers. I had a brilliant idea on one of my pages that selects some data from my mysql database. I first set the page up to display some info and an image, just one item, with a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.