Thursday, March 29, 2012

Deleting Records From A Table

I AM TRYING TO DELETE RECORDS FROM THE TABLE.

PLEASE CORRECT ME WITH THE SYNTAX

DELETE From DPT_NEW_BINS WHERE (
Select BIN,LEFT(ACCT_NUM_MIN,16), LEFT(ACCT_NUM_MAX,16), ISO_CTRY_CD, REGN_CD ,PROD_TYPE_CD FROM DPT_Temp_NEW_BINS o
WHERE EXISTS (SELECT BIN,LEFT(ACCT_NUM_MIN,16), LEFT(ACCT_NUM_MAX,16), ISO_CTRY_CD, REGN_CD ,PROD_TYPE_CD FROM DPT_NEW_BINS i
WHERE o.ACCT_NUM_MIN = i.ACCT_NUM_MIN AND o.ACCT_NUM_MAX = i.ACCT_NUM_MAX)

THE SELECT QUERY WORKS FOR ME BUT ONCE I ADD THE WHERE CLAUSE IT GIVES ME AN ERROR...CAN ANYBODY HELP ME OUT?

Quote:

Originally Posted by desirocks

I AM TRYING TO DELETE RECORDS FROM THE TABLE.

PLEASE CORRECT ME WITH THE SYNTAX

DELETE From DPT_NEW_BINS WHERE (
Select BIN,LEFT(ACCT_NUM_MIN,16), LEFT(ACCT_NUM_MAX,16), ISO_CTRY_CD, REGN_CD ,PROD_TYPE_CD FROM DPT_Temp_NEW_BINS o
WHERE EXISTS (SELECT BIN,LEFT(ACCT_NUM_MIN,16), LEFT(ACCT_NUM_MAX,16), ISO_CTRY_CD, REGN_CD ,PROD_TYPE_CD FROM DPT_NEW_BINS i
WHERE o.ACCT_NUM_MIN = i.ACCT_NUM_MIN AND o.ACCT_NUM_MAX = i.ACCT_NUM_MAX)

THE SELECT QUERY WORKS FOR ME BUT ONCE I ADD THE WHERE CLAUSE IT GIVES ME AN ERROR...CAN ANYBODY HELP ME OUT?


Please check the 'Closing Brackets' in ' Where ' to your delete query you haven't mention any condition...
Tell me if that works|||

Quote:

Originally Posted by desirocks

I AM TRYING TO DELETE RECORDS FROM THE TABLE.

PLEASE CORRECT ME WITH THE SYNTAX

DELETE From DPT_NEW_BINS WHERE (
Select BIN,LEFT(ACCT_NUM_MIN,16), LEFT(ACCT_NUM_MAX,16), ISO_CTRY_CD, REGN_CD ,PROD_TYPE_CD FROM DPT_Temp_NEW_BINS o
WHERE EXISTS (SELECT BIN,LEFT(ACCT_NUM_MIN,16), LEFT(ACCT_NUM_MAX,16), ISO_CTRY_CD, REGN_CD ,PROD_TYPE_CD FROM DPT_NEW_BINS i
WHERE o.ACCT_NUM_MIN = i.ACCT_NUM_MIN AND o.ACCT_NUM_MAX = i.ACCT_NUM_MAX)

THE SELECT QUERY WORKS FOR ME BUT ONCE I ADD THE WHERE CLAUSE IT GIVES ME AN ERROR...CAN ANYBODY HELP ME OUT?


Please POST your exact ERROR for my reference. The syntax of the DELETE statement is WRONG. Check below syntax:

DELETE FROM <table_name> WHERE <column_name> IN (SELECT <column_name FROM <table_name>)

No comments:

Post a Comment