473,804 Members | 3,067 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trying a delete with subquery

What is wrong with this? IT gives this error:
#1064 - 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 pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN ren

The select portion does what I want. test is a linking table between a
rentalpropertie s and a photos. I want to delete all the photos associated
with a certain property

New to MySQL, reading the manual and the o'reilly sql in a nutshell. Going
MAD!

DELETE FROM pp WHERE (
SELECT pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN rentalpropertie s AS r ON r.ndx = pp.propertyinde x
JOIN photos AS p ON pp.photoindex = p.photoindex
WHERE pp.propertyinde x = 4
)

--
Joel Goldstick
columbuswebmake rs.com
Jul 19 '05 #1
6 2452
Hiya Joel -
I had thought nested selects were not allowed in mySql ?
I could be wrong, of course . I DO SEE that you are using alias 'pp' there
a lot .
Did you mean to ?

I do a lot of client server work with VFP and mySql - so what I normally do
is make a vfp
table of just the pk's that I want to delete, the
do a scan..endscan operation in vfp , automatically generating the sql code
I want to send over,
and then send it over the wire in an odbc hook / technique called sql pass
through .

I noticed about 18 months ago [when I tried] that it wasn't possible to do a
nested select - so I gave up on trying anymore and moved on to data munging
in VFP.

I do know if you were using Oracle or MS-SQL - a nested select for delete
would work.
Anyway - check your usage on alias name of 'pp' - see where you have it
overused, change the name a few times, and see if that is meaningful.

IF IT'S NOT - then perhaps nested selects are still not allowed.
Which version of mySql are you using ?
mondo regards [Bill]
--
William Sanders / Electronic Filing Group Remove the DOT BOB to reply via
email.
Mondo Cool TeleCom -> http://www.efgroup.net/efgcog.html
Mondo Cool WebHosting -> http://www.efgroup.net/efglunar.html
Mondo Cool Satellites -> http://www.efgroup.net/sat
mySql / VFP / MS-SQL

"Joel Goldstick" <jo************ @columbuswebmak ers.com> wrote in message
news:2m******** **********@fe1. columbus.rr.com ...
What is wrong with this? IT gives this error:
#1064 - 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 pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN ren

The select portion does what I want. test is a linking table between a
rentalpropertie s and a photos. I want to delete all the photos associated
with a certain property

New to MySQL, reading the manual and the o'reilly sql in a nutshell. Going MAD!

DELETE FROM pp WHERE (
SELECT pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN rentalpropertie s AS r ON r.ndx = pp.propertyinde x
JOIN photos AS p ON pp.photoindex = p.photoindex
WHERE pp.propertyinde x = 4
)

--
Joel Goldstick
columbuswebmake rs.com

Jul 19 '05 #2
Hiya Joel -
I had thought nested selects were not allowed in mySql ?
I could be wrong, of course . I DO SEE that you are using alias 'pp' there
a lot .
Did you mean to ?

I do a lot of client server work with VFP and mySql - so what I normally do
is make a vfp
table of just the pk's that I want to delete, the
do a scan..endscan operation in vfp , automatically generating the sql code
I want to send over,
and then send it over the wire in an odbc hook / technique called sql pass
through .

I noticed about 18 months ago [when I tried] that it wasn't possible to do a
nested select - so I gave up on trying anymore and moved on to data munging
in VFP.

I do know if you were using Oracle or MS-SQL - a nested select for delete
would work.
Anyway - check your usage on alias name of 'pp' - see where you have it
overused, change the name a few times, and see if that is meaningful.

IF IT'S NOT - then perhaps nested selects are still not allowed.
Which version of mySql are you using ?
mondo regards [Bill]
--
William Sanders / Electronic Filing Group Remove the DOT BOB to reply via
email.
Mondo Cool TeleCom -> http://www.efgroup.net/efgcog.html
Mondo Cool WebHosting -> http://www.efgroup.net/efglunar.html
Mondo Cool Satellites -> http://www.efgroup.net/sat
mySql / VFP / MS-SQL

"Joel Goldstick" <jo************ @columbuswebmak ers.com> wrote in message
news:2m******** **********@fe1. columbus.rr.com ...
What is wrong with this? IT gives this error:
#1064 - 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 pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN ren

The select portion does what I want. test is a linking table between a
rentalpropertie s and a photos. I want to delete all the photos associated
with a certain property

New to MySQL, reading the manual and the o'reilly sql in a nutshell. Going MAD!

DELETE FROM pp WHERE (
SELECT pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN rentalpropertie s AS r ON r.ndx = pp.propertyinde x
JOIN photos AS p ON pp.photoindex = p.photoindex
WHERE pp.propertyinde x = 4
)

--
Joel Goldstick
columbuswebmake rs.com

Jul 19 '05 #3
Hiya Joel -
I had thought nested selects were not allowed in mySql ?
I could be wrong, of course . I DO SEE that you are using alias 'pp' there
a lot .
Did you mean to ?

I do a lot of client server work with VFP and mySql - so what I normally do
is make a vfp
table of just the pk's that I want to delete, the
do a scan..endscan operation in vfp , automatically generating the sql code
I want to send over,
and then send it over the wire in an odbc hook / technique called sql pass
through .

I noticed about 18 months ago [when I tried] that it wasn't possible to do a
nested select - so I gave up on trying anymore and moved on to data munging
in VFP.

I do know if you were using Oracle or MS-SQL - a nested select for delete
would work.
Anyway - check your usage on alias name of 'pp' - see where you have it
overused, change the name a few times, and see if that is meaningful.

IF IT'S NOT - then perhaps nested selects are still not allowed.
Which version of mySql are you using ?
mondo regards [Bill]
--
William Sanders / Electronic Filing Group Remove the DOT BOB to reply via
email.
Mondo Cool TeleCom -> http://www.efgroup.net/efgcog.html
Mondo Cool WebHosting -> http://www.efgroup.net/efglunar.html
Mondo Cool Satellites -> http://www.efgroup.net/sat
mySql / VFP / MS-SQL

"Joel Goldstick" <jo************ @columbuswebmak ers.com> wrote in message
news:2m******** **********@fe1. columbus.rr.com ...
What is wrong with this? IT gives this error:
#1064 - 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 pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN ren

The select portion does what I want. test is a linking table between a
rentalpropertie s and a photos. I want to delete all the photos associated
with a certain property

New to MySQL, reading the manual and the o'reilly sql in a nutshell. Going MAD!

DELETE FROM pp WHERE (
SELECT pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN rentalpropertie s AS r ON r.ndx = pp.propertyinde x
JOIN photos AS p ON pp.photoindex = p.photoindex
WHERE pp.propertyinde x = 4
)

--
Joel Goldstick
columbuswebmake rs.com

Jul 19 '05 #4
I have had similar problems in the past.

The easiest way I have found is to do the initial select, pass this to
an array and then manipulate the array with a second SQL statement.

Seems to work for me, just fine.

"Joel Goldstick" <jo************ @columbuswebmak ers.com> wrote in message news:<2m******* ***********@fe1 .columbus.rr.co m>...
What is wrong with this? IT gives this error:
#1064 - 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 pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN ren

The select portion does what I want. test is a linking table between a
rentalpropertie s and a photos. I want to delete all the photos associated
with a certain property

New to MySQL, reading the manual and the o'reilly sql in a nutshell. Going
MAD!

DELETE FROM pp WHERE (
SELECT pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN rentalpropertie s AS r ON r.ndx = pp.propertyinde x
JOIN photos AS p ON pp.photoindex = p.photoindex
WHERE pp.propertyinde x = 4
)

Jul 19 '05 #5
I have had similar problems in the past.

The easiest way I have found is to do the initial select, pass this to
an array and then manipulate the array with a second SQL statement.

Seems to work for me, just fine.

"Joel Goldstick" <jo************ @columbuswebmak ers.com> wrote in message news:<2m******* ***********@fe1 .columbus.rr.co m>...
What is wrong with this? IT gives this error:
#1064 - 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 pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN ren

The select portion does what I want. test is a linking table between a
rentalpropertie s and a photos. I want to delete all the photos associated
with a certain property

New to MySQL, reading the manual and the o'reilly sql in a nutshell. Going
MAD!

DELETE FROM pp WHERE (
SELECT pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN rentalpropertie s AS r ON r.ndx = pp.propertyinde x
JOIN photos AS p ON pp.photoindex = p.photoindex
WHERE pp.propertyinde x = 4
)

Jul 19 '05 #6
I have had similar problems in the past.

The easiest way I have found is to do the initial select, pass this to
an array and then manipulate the array with a second SQL statement.

Seems to work for me, just fine.

"Joel Goldstick" <jo************ @columbuswebmak ers.com> wrote in message news:<2m******* ***********@fe1 .columbus.rr.co m>...
What is wrong with this? IT gives this error:
#1064 - 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 pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN ren

The select portion does what I want. test is a linking table between a
rentalpropertie s and a photos. I want to delete all the photos associated
with a certain property

New to MySQL, reading the manual and the o'reilly sql in a nutshell. Going
MAD!

DELETE FROM pp WHERE (
SELECT pp.propertyinde x, pp.photoindex
FROM test AS pp
JOIN rentalpropertie s AS r ON r.ndx = pp.propertyinde x
JOIN photos AS p ON pp.photoindex = p.photoindex
WHERE pp.propertyinde x = 4
)

Jul 19 '05 #7

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

Similar topics

0
2397
by: Vikram Vaswani | last post by:
Hi all, I have the following two tables: mysql> SELECT * FROM clients; +-----+-----------------------------+ | cid | cname | +-----+-----------------------------+ | 101 | JV Real Estate | | 102 | ABC Talent Agency |
2
20479
by: Rotsj | last post by:
Hi, if i run the following query: select * from std_order_lines sol where exists(select * from std_orders so, customers c where so.customers_id = c.customers_id and c.test_customer = 'Y' and so.order_id = sol.order_id)
2
2314
by: Matthew Wells | last post by:
I want to delete records from the "one" table of a one to may relationship. There are no actual Access relationships set up. The "one" table has a single field PK and the "many" table has a two field PK. This code works when executed from a module (both DAO and ADO work), but not from the query window. DELETE a1.*, a2.Field1 FROM a1 LEFT JOIN a2 ON a1.Field1 = a2.Field1 WHERE (((a2.Field1) Is Null));
5
4313
by: Mike Wiseley | last post by:
I would like to create a delete query that consists of two tables linked together. One table will be the target for the deletions while the other table's equi-joins will tell the delete query which records in the target table to delete. When you try to do this, an error message appears asking you which table you want to delete records from (of the two tables shown in the query). How do you tell Access what to do in this case???
14
8089
by: Darin | last post by:
I have a table that I want to delete specific records from based on data in other tables. I'm more familiar with Access '97, but am now using 2003, but the database is in 2000 format. In '97, I think I could have easily done this using joins, but I kept getting "could not delete from specified tables" errors. Some google searching has indicated I need to use a subquery. After many failed attempts with different approaches, I finally...
14
5725
by: mike | last post by:
I'm using postgresl 7.3.2 and have a query that executes very slowly. There are 2 tables: Item and LogEvent. ItemID (an int4) is the primary key of Item, and is also a field in LogEvent. Some ItemIDs in LogEvent do not correspond to ItemIDs in Item, and periodically we need to purge the non-matching ItemIDs from LogEvent. The query is: delete from LogEvent where EventType != 'i' and ItemID in
1
2028
by: JC | last post by:
Hello, I am trying to change a select, find duplicates, query into a delete query. I want to get rid of the records in the main table "tblHurnsHistory." I changed the Find Duplicates query to a Delete query. I then received an input box looking for criteria that states," Enter parameter value qryHurnsHistory.Grads_creditsEarned
1
3944
by: codedhacker | last post by:
I have a piece of code that uses the db-library with sql server 2000/2005 and runs the following delete statement: DELETE FROM TABLE1 WHERE COL1 IN( 'Some Val1' ) AND COL2 IN( 'Some Val2' ) AND Col3 IN( integer1 ) AND Col4 IN( integer2 ) AND Col5 IN( 'Some Val3' ) on TABLE1, uploads data into TABLE1 through bulk loading, calls a stored procedure that uses the data, and then deletes the data through the SAME delete statement...
8
2987
by: Michel Esber | last post by:
Hello, Env: DB2 V8 LUW FP16 running Linux create Table X (machine_id varchar(24) not null, ctime timestamp not null); create index iFoo on X (MACHINE_ID, CTIME) allow reverse scans; alter table X add primary key (MACHINE_ID, CTIME); Our C++ application inserts data into a table X using CLI array insert
0
9704
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
10558
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...
1
10302
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
10069
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...
1
7608
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
6844
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
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
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
3802
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.