|
Posted by Tim Roberts on 04/30/07 05:29
Jon <yu.jono@gmail.com> wrote:
>Hi,
>
>I'm having some trouble trying to get DELETE to work with SQLITE3 and
>PHP and was wondering if anyone could be of some assistance?
>
>I have verified that it is set up correctly and I'm able to insert /
>create / select from tables but I'm unable to delete specific entries.
>
>Given the following 2 tables:
>
>Table A Table B
>Name Cost Name Cost
>A 1 D
>3
>B 2 E
>5
>C 3 F
>7
>
>how would I delete entries with the same cost?
You want to delete from BOTH tables?
Deleting from one table is easy:
DELETE FROM tablea WHERE cost IN
(SELECT cost FROM tableb);
To delete from both tables, you'll have to copy the costs that are
duplicated into a temporary table, and then use that in a subselect. Or,
grab the SELECT results into a variable and construct the DELETE yourself.
SELECT tablea.cost FROM tablea,tableb WHERE tablea.cost=tableb.cost;
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
[Back to original message]
|