Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

SQL statement

Options
  • 02-10-2006 12:03pm
    #1
    Closed Accounts Posts: 289 ✭✭


    Hi what do i need to add to this stmt to delete the result ?

    select ct_cust1_text01,ct_address,ct_cust1_text09,count(*)from TABLE_NAME group by ct_cust1_text01,ct_address,ct_cust1_text09 having count(*) > 1


    i have tried delete * from TABLE_NAME where (select...)

    not great at SQL appreciate any help...


Comments

  • Registered Users Posts: 43,913 ✭✭✭✭Basq


    Try:
    DELETE from TABLE_NAME where (select...)

    No wildcard necessary!


  • Registered Users Posts: 4,188 ✭✭✭pH


    DELETE FROM .... with a GROUP BY and HAVING clause?

    try something like :

    DELETE FROM table_name where CUST_ID IN (
    .. Your select statement rewritten to select just cust_ids that match the criteria
    )


  • Registered Users Posts: 1,466 ✭✭✭Smoggy


    as Ph says , just use the primary key of your table in the select and then use in keyword IN as part of the delete.


Advertisement