If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > SQL delete query help -- very urgent

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-07, 10:29
subbukns subbukns is offline
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old 12-04-07, 10:33
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
... and cod3 is null
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 12-04-07, 10:33
subbukns subbukns is offline
Registered User
 
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;
Reply With Quote
  #4 (permalink)  
Old 12-04-07, 10:35
subbukns subbukns is offline
Registered User
 
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
Reply With Quote
  #5 (permalink)  
Old 12-04-07, 10:40
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by subbukns
Please suggest.
write an IF statement in whatever application language is calling the database
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On