473,465 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help with join, delete

I am not a sql person and could use some help with a delete...here is
what I want:

I have the following tables/fields (only including necessary fields)

answers
result_id

results
result_id
points

I want to delete the records for result_id from both tables when
points in the results table <50

Thanks in advance for any assistance.

Mike
Jul 20 '05 #1
5 2829
Mike wrote:
I have the following tables/fields (only including necessary fields)

answers
result_id

results
result_id
points

I want to delete the records for result_id from both tables when
points in the results table <50


This might help:
http://dev.mysql.com/doc/mysql/en/DELETE.html

But please note the part saying:
"From MySQL 4.0, you can specify multiple tables in the DELETE statement
to delete rows from one or more tables depending on a particular
condition in multiple tables. However, you cannot use ORDER BY or LIMIT
in a multiple-table DELETE.

The first multiple-table DELETE syntax is supported starting from MySQL
4.0.0. The second is supported starting from MySQL 4.0.2. The
table_references part lists the tables involved in the join. Its syntax
is described in section 14.1.7.1 JOIN Syntax. "
Jul 20 '05 #2
It help a little...But I still need some guidance.

This selects what I want:
SELECT * FROM answers, results WHERE
answers.result_id=results.result_id AND results.score <50

so I would think this would delete it:
DELETE FROM answers, results WHERE answers.result_id=results.result_id
AND results.score <50

but it doesn't, can anyone shed some light on it?

Thanks Mike

Aggro <sp**********@yahoo.com> wrote in message news:<3a***************@read3.inet.fi>...
Mike wrote:
I have the following tables/fields (only including necessary fields)

answers
result_id

results
result_id
points

I want to delete the records for result_id from both tables when
points in the results table <50


This might help:
http://dev.mysql.com/doc/mysql/en/DELETE.html

But please note the part saying:
"From MySQL 4.0, you can specify multiple tables in the DELETE statement
to delete rows from one or more tables depending on a particular
condition in multiple tables. However, you cannot use ORDER BY or LIMIT
in a multiple-table DELETE.

The first multiple-table DELETE syntax is supported starting from MySQL
4.0.0. The second is supported starting from MySQL 4.0.2. The
table_references part lists the tables involved in the join. Its syntax
is described in section 14.1.7.1 JOIN Syntax. "

Jul 20 '05 #3
Mike wrote:
so I would think this would delete it:
DELETE FROM answers, results WHERE answers.result_id=results.result_id
AND results.score <50

but it doesn't, can anyone shed some light on it?


What version of MySQL server you are using?
Jul 20 '05 #4
It help a little...But I still need some guidance.

This selects what I want:
SELECT * FROM answers, results WHERE
answers.result_id=results.result_id AND results.score <50

so I would think this would delete it:
DELETE FROM answers, results WHERE answers.result_id=results.result_id
AND results.score <50

but it doesn't, can anyone shed some light on it?

Thanks Mike

Aggro <sp**********@yahoo.com> wrote in message news:<3a***************@read3.inet.fi>...
Mike wrote:
I have the following tables/fields (only including necessary fields)

answers
result_id

results
result_id
points

I want to delete the records for result_id from both tables when
points in the results table <50


This might help:
http://dev.mysql.com/doc/mysql/en/DELETE.html

But please note the part saying:
"From MySQL 4.0, you can specify multiple tables in the DELETE statement
to delete rows from one or more tables depending on a particular
condition in multiple tables. However, you cannot use ORDER BY or LIMIT
in a multiple-table DELETE.

The first multiple-table DELETE syntax is supported starting from MySQL
4.0.0. The second is supported starting from MySQL 4.0.2. The
table_references part lists the tables involved in the join. Its syntax
is described in section 14.1.7.1 JOIN Syntax. "

Jul 20 '05 #5
Mike wrote:
so I would think this would delete it:
DELETE FROM answers, results WHERE answers.result_id=results.result_id
AND results.score <50

but it doesn't, can anyone shed some light on it?


What version of MySQL server you are using?
Jul 20 '05 #6

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

Similar topics

0
by: Peter A. Schott | last post by:
Got a strange scenario going on here in that I could have sworn this worked yesterday. I am issuing binary retrieval calls to an FTP server, writing to a file, close the file, then removing the...
1
by: Mike | last post by:
I am not a sql person and could use some help with a delete...here is what I want: I have the following tables/fields (only including necessary fields) answers result_id results result_id
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
3
by: William Case | last post by:
I cannot believe I'm having this much trouble doing such a simple thing! I have two tables with identical structure. I can use an A2K select query to show the records in table 1 that match...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: Matthew Warren | last post by:
I have the following piece of code, taken from a bigger module, that even as I was writing I _knew_ there were better ways of doing it, using a parser or somesuch at least, but learning how wasn't...
1
by: TanmayQuery | last post by:
I have written a sql procedure, i want to pass delared variable @cnt in line131,char24 below is the PL Code: CREATE PROCEDURE PL @dt varchar(10), @stock as bit --1/true for updated and 0/false...
0
by: davidsavill | last post by:
Hi All, I am migrating a database from Firebird/Interbase to DB2 and have having issues with the stored procedures/functions. I have a number of functions that loop over a FOR loop, each pass...
4
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
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
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,...
0
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...
0
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.