473,756 Members | 5,660 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 4011
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
1990
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
4902
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
3948
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
2519
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
2407
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
4639
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
6092
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
970
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
38518
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
9487
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
9297
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
10069
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
9904
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
9884
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
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.