Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

SQL statement

  • 02-10-2006 11:03AM
    #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, Registered Users 2 Posts: 45,160 ✭✭✭✭Basq


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

    No wildcard necessary!


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 1,454 ✭✭✭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