473,856 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql 4.1 win2000 SP3, UPDATE: bug or what?

hello i have mysql 4.1 with win2000 SP3, i know that it is only an
alpha and i don't know if someone else has already posted this
problem:
when i execute this sql

UPDATE tableX SET fieldX=valueX
WHERE id IN (SELECT tX.id FROM tableX AS tX WHERE tX.fieldY=value Y AND
filedZ=valueZ);
(note that tableX and tableX are the same tables)

i have this error
"You can't specify target table 'tableX' for update in FROM clause"
while the same sql in access2000 works without problem.

do i have to use another syntax or is it a bug?
Jul 19 '05 #1
5 4018
execuse but i'm italian and i'm not so good in english...
you said i've to look in the manual, but 1.7.4.1 SubSELECTs is not in
the manual of mysql4.1alpha, it is in the one of mysql 4.0.13, and
i've got mysql4.1 aplha.
i only wonder why the sql with subselect

UPDATE tableX SET fieldX=valueX
WHERE id IN (SELECT tX.id FROM tableX AS tX WHERE tX.fieldY=value Y AND
filedZ=valueZ);

doesn't work while others sql with subselect, also very complicated,
works without any problem in mysql 4.1alpha

bye
ps excuse me if i've done a double post

"ybd" <w3**@yinboda.c om> wrote in message news:<bg******* ***@news.yaako. com>...
I think that you need read mysql manual at first~~~. Look at
-----------------
1.7.4.1 SubSELECTs

MySQL Server currently only supports nested queries of the form INSERT ...
SELECT ... and REPLACE ... SELECT .... You can, however, use the function
IN() in other contexts. Subselects are currently being implemented in the
4.1 development tree.

Meanwhile, you can often rewrite the query without a subselect:

SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
This can be rewritten as:

SELECT table1.* FROM table1,table2 WHERE table1.id=table 2.id;
The queries:

SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2
WHERE table1.id=table 2.id);
Can be rewritten as:

SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table 2.id
WHERE table2.id IS NULL;
For more complicated subqueries you can often create temporary tables to
hold the subquery. In some cases, however, this option will not work. The
most frequently encountered of these cases arises with DELETE statements,
for which standard SQL does not support joins (except in subselects). For
this situation there are two options available until subqueries are
supported by MySQL Server.

The first option is to use a procedural programming language (such as Perl
or PHP) to submit a SELECT query to obtain the primary keys for the records
to be deleted, and then use these values to construct the DELETE statement
(DELETE FROM ... WHERE ... IN (key1, key2, ...)).

The second option is to use interactive SQL to construct a set of DELETE
statements automatically, using the MySQL extension CONCAT() (in lieu of the
standard || operator). For example:

SELECT CONCAT('DELETE FROM tab1 WHERE pkid = ', "'", tab1.pkid, "'", ';')
FROM tab1, tab2
WHERE tab1.col1 = tab2.col2;
You can place this query in a script file and redirect input from it to the
mysql command-line interpreter, piping its output back to a second instance
of the interpreter:

shell> mysql --skip-column-names mydb < myscript.sql | mysql mydb
MySQL Server 4.0 supports multi-table deletes that can be used to
efficiently delete rows based on information from one table or even from
many tables at the same time.

------------------------

Good Luck

"red85" <ho*******@inwi nd.it> ????
news:25******** *************** ***@posting.goo gle.com...
hello i have mysql 4.1 with win2000 SP3, i know that it is only an
alpha and i don't know if someone else has already posted this
problem:
when i execute this sql

UPDATE tableX SET fieldX=valueX
WHERE id IN (SELECT tX.id FROM tableX AS tX WHERE tX.fieldY=value Y AND
filedZ=valueZ);
(note that tableX and tableX are the same tables)

i have this error
"You can't specify target table 'tableX' for update in FROM clause"
while the same sql in access2000 works without problem.

do i have to use another syntax or is it a bug?

Jul 19 '05 #2
execuse but i'm italian and i'm not so good in english...
you said i've to look in the manual, but 1.7.4.1 SubSELECTs is not in
the manual of mysql4.1alpha, it is in the one of mysql 4.0.13, and
i've got mysql4.1 aplha.
i only wonder why the sql with subselect

UPDATE tableX SET fieldX=valueX
WHERE id IN (SELECT tX.id FROM tableX AS tX WHERE tX.fieldY=value Y AND
filedZ=valueZ);

doesn't work while others sql with subselect, also very complicated,
works without any problem in mysql 4.1alpha

bye
ps excuse me if i've done a double post

"ybd" <w3**@yinboda.c om> wrote in message news:<bg******* ***@news.yaako. com>...
I think that you need read mysql manual at first~~~. Look at
-----------------
1.7.4.1 SubSELECTs

MySQL Server currently only supports nested queries of the form INSERT ...
SELECT ... and REPLACE ... SELECT .... You can, however, use the function
IN() in other contexts. Subselects are currently being implemented in the
4.1 development tree.

Meanwhile, you can often rewrite the query without a subselect:

SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
This can be rewritten as:

SELECT table1.* FROM table1,table2 WHERE table1.id=table 2.id;
The queries:

SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2
WHERE table1.id=table 2.id);
Can be rewritten as:

SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table 2.id
WHERE table2.id IS NULL;
For more complicated subqueries you can often create temporary tables to
hold the subquery. In some cases, however, this option will not work. The
most frequently encountered of these cases arises with DELETE statements,
for which standard SQL does not support joins (except in subselects). For
this situation there are two options available until subqueries are
supported by MySQL Server.

The first option is to use a procedural programming language (such as Perl
or PHP) to submit a SELECT query to obtain the primary keys for the records
to be deleted, and then use these values to construct the DELETE statement
(DELETE FROM ... WHERE ... IN (key1, key2, ...)).

The second option is to use interactive SQL to construct a set of DELETE
statements automatically, using the MySQL extension CONCAT() (in lieu of the
standard || operator). For example:

SELECT CONCAT('DELETE FROM tab1 WHERE pkid = ', "'", tab1.pkid, "'", ';')
FROM tab1, tab2
WHERE tab1.col1 = tab2.col2;
You can place this query in a script file and redirect input from it to the
mysql command-line interpreter, piping its output back to a second instance
of the interpreter:

shell> mysql --skip-column-names mydb < myscript.sql | mysql mydb
MySQL Server 4.0 supports multi-table deletes that can be used to
efficiently delete rows based on information from one table or even from
many tables at the same time.

------------------------

Good Luck

"red85" <ho*******@inwi nd.it> ????
news:25******** *************** ***@posting.goo gle.com...
hello i have mysql 4.1 with win2000 SP3, i know that it is only an
alpha and i don't know if someone else has already posted this
problem:
when i execute this sql

UPDATE tableX SET fieldX=valueX
WHERE id IN (SELECT tX.id FROM tableX AS tX WHERE tX.fieldY=value Y AND
filedZ=valueZ);
(note that tableX and tableX are the same tables)

i have this error
"You can't specify target table 'tableX' for update in FROM clause"
while the same sql in access2000 works without problem.

do i have to use another syntax or is it a bug?

Jul 19 '05 #3
UP!!
Jul 19 '05 #4
UP!!
Jul 19 '05 #5
UP!!
Jul 19 '05 #6

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

Similar topics

0
1997
by: Gary Broughton | last post by:
Thanks to everybody for all your help and advice. It seems Linux is going to HAVE to be the next step, but while I know sod all about it, I have enlisted the help of a colleague to assist with that side of things. So I shall crack on with that, and subsequently let you know what the outcome is. :-) Thanks again Gary -----Original Message----- From: Nils Valentin
2
4909
by: Bruce W...1 | last post by:
I've got MySQL running as a service on my Windows 2000 box. And I can work with it using a command window (DOS box). I used the default install of MySQL and here's what status says: mysql> status -------------- mysql Ver 12.21 Distrib 4.0.15, for Win95/Win98 Connection id: 5 Current database:
0
3957
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
9
2527
by: Sheldon | last post by:
Hi, I have a mysql setting problem that is driving me mad. Hopefully someone can give some advice: On the local network I have windows 2000/iis5 machine running our intranet site, with php and mysql working ok. Anonymous access is disabled, and root has been assigned a password and given full access to all tables from all hosts (i reliase this isn't secure but its only temporary for testing)
10
2418
by: JP Bless | last post by:
Hi all, I have a database Access/MSDE and would like to have a website so users can search the data and update some records/fields through the website.... And I have high speed internet connection. Is it possible to setup/host a website using WIN2000/XP machine? Must I have static IP and not dynamic one obtained when my router connects to the ISP? What kind of internet connection do I need to have to be able to have/host a website on my...
15
4662
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
3
6097
by: Juan Antonio Villa | last post by:
Hello, I'm having a problem replicating a simple database using the binary log replication, here is the problem: When the master sends an update to the slave, an example update reads as follows: UPDATE MainInfo SET dAddress='38 Holland Blvd', dCity='miami', dState='FL', dZip='33000', dCountry='USA', dPhone='999987565', dNum='AC15857', dName='Michael A Scott' WHERE did=22'
0
975
by: Zorglub | last post by:
Hi, this post only occurs on Win2000 5.00.2195 SP4, it's work perfectly on Win XP Sample can be found on http://www.akadia.com/services/dotnet_databinding.html Where's the difference on the twos platforms ??? Thx >Hi,
6
38545
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get through this without much trouble. Programming knowledge is not required. Index What is SQL? Why MySQL? Installing MySQL. Using the MySQL command line interface
0
9922
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9766
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11066
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10702
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10801
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10391
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9536
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7935
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5963
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.