473,395 Members | 1,676 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,395 software developers and data experts.

cursor needed!?

Hello mysql experts,

i would like insert only the first "value" from every member into the table
members - but different counts exist in table members_action.

UPDATE members set value1=
(Select value from members_action where value1=
(Select min(id) from members_action where
members.member_no=members_action.member_no));

This works not, because i didn't get a result set, have anybody
an example using a cursor for this problem in mysql if is necessary -
i'm using 5.02alpha!?

Many thanks,
Christian
Jul 20 '05 #1
2 1355
christian wrote:
UPDATE members set value1=
(Select value from members_action where value1=
(Select min(id) from members_action where
members.member_no=members_action.member_no));


MySQL supports a SQL enhancement that permits a join in an UPDATE or
DELETE statement. See the documentation on the UPDATE statement.

Another method of solving this problem is to run a SELECT on
members_action, with literal strings to form the necessary UPDATE
statements to change records in the members table. Then run the result
of this query as a SQL script.

Regards,
Bill K.
Jul 20 '05 #2

"christian" <oz***@web.de> wrote in message
news:1a**************************@posting.google.c om...
Hello mysql experts,

i would like insert only the first "value" from every member into the table members - but different counts exist in table members_action.

UPDATE members set value1=
(Select value from members_action where value1=
(Select min(id) from members_action where
members.member_no=members_action.member_no));

This works not, because i didn't get a result set, have anybody
an example using a cursor for this problem in mysql if is necessary -
i'm using 5.02alpha!?

Many thanks,
Christian


This should work with your version of mysql:

UPDATE members set value1 =
(SELECT value FROM members_action WHERE members_action.member_no =
members.member_no AND
id = (
SELECT min(id) from members_action WHERE members_action.member_no =
members.member_no))

Regards,
Rich R.
Jul 20 '05 #3

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

Similar topics

15
by: Philip Mette | last post by:
I am begginner at best so I hope someone that is better can help. I have a stored procedure that updates a view that I wrote using 2 cursors.(Kind of a Inner Loop) I wrote it this way Because I...
2
by: Csaba2000 | last post by:
The following code has me so confused, I don't even know the right questions to ask. Opera 7.01 and IE 5.5 both exhibit behaviours I don't understand while NN 6.1 seems to ignore me altogether. ...
1
by: jfro | last post by:
After trying every way I could come up with I can't get a filter clause to work with a passed variable ... I have a cursor that pulls a filter string from a table (works OK), then I want to use...
10
by: Neil | last post by:
I need to get two values from a complex SQL statement which returns a single record and use those two values to update a single record in a table. In order to assign those two values to variables...
7
by: William Gill | last post by:
I have been trying to pass parameters as indicated in the api. when I use: sql= 'select * from %s where cusid = %s ' % name,recID) Cursor.execute(sql) it works fine, but when I try : sql=...
3
by: Shawn Mesiatowsky | last post by:
how do you change the mouse cursor to an hour glass? thanks for your help
4
by: Strahimir Antoljak | last post by:
I want to track the cursor location relative to a control on the form. I am aware of System.Windows.Forms.Cursor.Position which provides absolute cursor position relative to the screen. With right...
12
by: Lucky | last post by:
Hi guys! i want to create one cursor in the t-sql. the problem is i want to use stored procedure instead of select command in cursor. can anyone tell me how can i use stored procedure's o/p to...
7
by: mmckinnon | last post by:
Hi All, I have a mainform that hold a template for house remodeling. Then I have a subform that holds the tasks needed to accomplish the house remodel. The subfrom is a list of continuous...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.