Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2013
    Posts
    6

    Unanswered: Delete multiple table records in single query

    Hi All,

    I need for following data in single query....
    Table Master
    -------------
    field1 field2
    2201 asd
    2202 kjo
    2204 pws
    2207 tre

    table1
    --------
    field1 field2
    2201 asd
    2206 kjo
    2203 pws
    2207 tre

    table2 upto ... table 5
    -------
    field1 field2
    2202 asd
    2204 kjo
    2209 pws
    2203 tre

    delete query using after I need results for below
    Result:
    ------
    table1
    --------
    field1 field2
    2206 kjo
    2203 pws

    table2
    -------
    field1 field2
    2202 asd
    2209 pws
    2203 tre

    Master table records for unique and others table records are duplicates. So remove duplicate records based on mater table.

    Pls help me....

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    I need for following data in single query....
    Table Master
    -------------
    field1 field2
    2201 asd
    2202 kjo
    2204 pws
    2207 tre

    table2
    -------
    field1 field2
    2202 asd
    2204 kjo
    2209 pws
    2203 tre

    delete query using after I need results for below
    table2
    -------
    field1 field2
    2202 asd
    2209 pws
    2203 tre
    Why
    2202 asd /* was preserved */
    2204 kjo /* was deleted */
    ?

  3. #3
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    table1 ... table5 looks having same structure(same number of columns and data type of each column).

    If it was right, please try to delete from "UNION ALL tables",
    like...
    Code:
    DELETE FROM
    (SELECT * FROM table1
     UNION ALL
     SELECT * FROM table2
    ...
    ...
     UNION ALL
     SELECT * FROM table5
    ) AS t/*arget*/
     WHERE ... /* this condititons might be an issue */
    ;
    Last edited by tonkuma; 08-19-14 at 01:52. Reason: correct a spell t/*aget*/

  4. #4
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Please report your result from my suggested query.

    Even if you couldn't understand the query,
    you can try the query in your environment,
    and report the result of the query!


    Did you got error message(s)?
    or
    the results were different from your expectations?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •