• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

delete sql

 
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i run:
select * from
emp a, empno b
whre a.empname = b.empname
and it return some result set.
what i should do it delete these record?
if i use
delete from
emp a, empno b
whre a.empname = b.empname
Error: ORA-00933: SQL command not properly ended
thanks!
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U can't perform DML(insert/update/delete) operations on more than one table at a time..even if u are referring to the same table by means of alias.
I think what u intend to do is delete duplicate records.
If that is the case, u can try the following..

DELETE FROM EMP A WHERE ROWID > (
SELECT MIN(ROWID) FROM EMP B
WHERE A.EMPNAME = B.EMPNAME);

regards
Rajeshwari
 
Rajeshwari Natarajan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
u can try this..
DELETE FROM EMP A WHERE A.EMPNAME IN (SELECT B.EMPNAME FROM EMPNO B)
 
Jackie Wang
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
Rajeshwari
 
Your mother is a hamster and your father smells of tiny ads!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic