![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have two tables : t1(a1 integer) and t2(a1 integer). I am trying a dlete statement which works in Oracle but not on MySql server. delete *from t2 t *where *t.a1 in (select b.a1 from t1 b *where b..a1 between 2 and 5) ; What is wrong with the syntax of that statement ? |
#3
| |||
| |||
|
|
On 5 mar, 09:59, "dn.p... (AT) gmail (DOT) com" <dn.p... (AT) gmail (DOT) com> wrote: I have two tables : t1(a1 integer) and t2(a1 integer). I am trying a dlete statement which works in Oracle but not on MySql server. delete =A0from t2 t =A0where =A0t.a1 in (select b.a1 from t1 b =A0where b= ..a1 between 2 and 5) ; What is wrong with the syntax of that statement ? AFAIK your query is valid, but MySQL does not support alias in delete statements (at least I could not find any support for it in the documentation). Try: delete from t2 where t2.a1 in ( select b.a1 from t1 as b where b.a1 between 2 and 5 ); |
#4
| |||
| |||
|
|
In article <ef52f90a-9b3c-46bd-b5c7-acfa84e077ba (AT) g7g2000yqe (DOT) googlegroups.com>, Lennart <erik.lennart.jonsson (AT) gmail (DOT) com> wrote: On 5 mar, 09:59, "dn.p... (AT) gmail (DOT) com" <dn.p... (AT) gmail (DOT) com> wrote: I have two tables : t1(a1 integer) and t2(a1 integer). I am trying a dlete statement which works in Oracle but not on MySql server. delete =A0from t2 t =A0where =A0t.a1 in (select b.a1 from t1 b =A0where b= ..a1 between 2 and 5) ; What is wrong with the syntax of that statement ? AFAIK your query is valid, but MySQL does not support alias in delete statements (at least I could not find any support for it in the documentation). Try: delete from t2 where t2.a1 in ( select b.a1 from t1 as b where b.a1 between 2 and 5 ); Or, much more simply, DELETE FROM t2 WHERE a1 BETWEEN 2 AND 5; |
#5
| |||
| |||
|
|
I have two tables : t1(a1 integer) and t2(a1 integer). I am trying a dlete statement which works in Oracle but not on MySql server. delete from t2 t where t.a1 in (select b.a1 from t1 b where b.a1 between 2 and 5) ; What is wrong with the syntax of that statement ? |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Doug Miller wrote: In article ef52f90a-9b3c-46bd-b5c7-acfa84e077ba...oglegroups.com>, Lennart erik.lennart.jonsson (AT) gmail (DOT) com> wrote: On 5 mar, 09:59, "dn.p... (AT) gmail (DOT) com" <dn.p... (AT) gmail (DOT) com> wrote: I have two tables : t1(a1 integer) and t2(a1 integer). I am trying a dlete statement which works in Oracle but not on MySql server. delete =A0from t2 t =A0where =A0t.a1 in (select b.a1 from t1 b =A0where b= ..a1 between 2 and 5) ; What is wrong with the syntax of that statement ? AFAIK your query is valid, but MySQL does not support alias in delete statements (at least I could not find any support for it in the documentation). Try: delete from t2 where t2.a1 in ( select b.a1 from t1 as b where b.a1 between 2 and 5 ); Or, much more simply, DELETE FROM t2 WHERE a1 BETWEEN 2 AND 5; You're query will delete all rows in t2 where a1 is between 2 and 5. The user only wants to delete the rows where a1 is between 2 and 5 AND that value exists in t1.a1. Yes, you're right. I missed that first time through. |
#8
| |||
| |||
|
|
The MySql version is 4.0.26 ; |
#9
| |||
| |||
|
|
The MySql version is 4.0.26 ; Each of the following command fails with Error 1064. create table t1 (a1 integer) ; create table t2 (a1 integer) ; Command : delete *from t2 * where *a1 in (select a1 from t1 * * * * where a1 between 2 and 5) ; Message : You have an error in your SQL syntax. *Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select a1 from t1 * where a1 between 2 and 5)' at line 1 Command : delete *from t2 * where *a1 in (select b.a1 from t1 b * * * * where b.a1 between 2 and 5) ; * Or use t2.a1 instead ofjust a1 . . Command : delete *from t2 a *where *a.a1 in (select b.a1 from t1 b * * * * where b.a1 between 2 and 5) ; Now the error-message changes in its content. Message : You have an error in your SQL syntax. *Check the manual that corresponds to your MySQL server version for the right syntax to use near 'a *where *a.a1 in (select b.a1 from t1 b * where b.a1 between ===== |
#10
| |||
| |||
|
|
On 5 Mar, 13:44, "dn.p... (AT) gmail (DOT) com" <dn.p... (AT) gmail (DOT) com> wrote: The MySql version is 4.0.26 ; Each of the following command fails with Error 1064. create table t1 (a1 integer) ; create table t2 (a1 integer) ; Command : delete *from t2 * where *a1 in (select a1 from t1 * * * * where a1 between 2 and 5) ; Message : You have an error in your SQL syntax. *Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select a1 from t1 * where a1 between 2 and 5)' at line 1 Command : delete *from t2 * where *a1 in (select b.a1 from t1 b * * * * where b.a1 between 2 and 5) ; * Or use t2.a1 instead of just a1 . . Command : delete *from t2 a *where *a.a1 in (select b.a1 from t1 b * * * * where b.a1 between 2 and 5) ; Now the error-message changes in its content. Message : You have an error in your SQL syntax. *Check the manual that corresponds to your MySQL server version for the right syntax to use near 'a *where *a.a1 in (select b.a1 from t1 b * where b.a1 between ===== This should be done with a NOT NULL test on a LEFT JOIN |
![]() |
| Thread Tools | |
| Display Modes | |
| |