• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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
 
Always! Wait. Never. Shut up. Look at this tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic