This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes delete sql not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "delete sql not working " Watch "delete sql not working " New topic
Author

delete sql not working

bhavin ragha
Greenhorn

Joined: Mar 28, 2012
Posts: 17
trying to delete all information relating to cd005

im putting in the statement below. But i get the error: near ",": syntax error... (im using sqlite)

delete from cds, bands, band_members, releases
where band_members.band_id = bands.band_id
and band_members.band_id = releases.band_id
and cds.cd_id = releases.cd_id
and cds.cd_id = 'cd005'

when i change delete to select * i get the values that i want to delete.
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19725
    
  10

You can only delete rows from one table using the SQL DELETE statement.
bhavin ragha
Greenhorn

Joined: Mar 28, 2012
Posts: 17
Paul Clapham wrote:You can only delete rows from one table using the SQL DELETE statement.


so how do i delete all data relating to cd005
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63208
    
  69

One table at a time.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 523
Or if you are allowed to set cascade delete option.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: delete sql not working
 
It's not a secret anymore!