• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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
reply
    Bookmark Topic Watch Topic
  • New Topic