Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2007
    Posts
    10

    SQL delete query help -- very urgent

    code_tbl description:

    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    CDE1 NOT NULL CHAR(1)
    CDE3 CHAR(4)
    CDE2 CHAR(2)


    sample data in table:

    cde1 cde3 cde2
    ---- ---- ----
    1 ab
    2 1111
    3 1234 cd
    4 1234 de

    Please note that I have nulls in col2 & col3. database is ORACLE.

    How do I delete the data from code_tbl wherein I have to use all of the column names in where clause.

    Please suggest me the correct SQL query.

    I am trying to use following SQL but it is not deleting the row.

    SQL> delete from code_tbl where cde1 = '1' and cde2 = 'NY' and cod3 = null;

    Thanks in advance,
    KNS

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    ... and cod3 is null
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2007
    Posts
    10

    correction in SQL query that i am using

    delete from code_tbl where cde1 = '1' and cde2 = 'ab' and cod3 = null;

  4. #4
    Join Date
    Feb 2007
    Posts
    10
    I can't hard-code "cde3 is null" because sometimes i will be having value in that and if i have values...I got to use that in my query. Please suggest.

    Thanks

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by subbukns
    Please suggest.
    write an IF statement in whatever application language is calling the database
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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