• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

SQL Remove.

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on a Database GUI that has Text Fields.

I have the following Buttons Workings, Insert, Connect to Database, Next, Previous, Insert and Search by last Name.

I am Trying to Get the Delete Button Working, which i am getting Errors.










I am Getting the Following Errors.

 
Sheriff
Posts: 26961
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think that's a valid DELETE statement. You appear to have started to write a DELETE and then tacked on part of the INSERT syntax at the end of it. The simplest form of DELETE is


 
david foley
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried

Delete from patient where patientId = ?

But that does not seem to work either

Some how I am trying
To be able to remove a account that has populated the text fields of the program
 
Paul Clapham
Sheriff
Posts: 26961
84
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that's the way to do it. So if it "doesn't work" then you must not be doing it right. But have a look at our FAQ entry ItDoesntWorkIsUseless (<== click on that link) and then post accordingly.
 
david foley
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, by looking at my code above where do you think i am after going wrong.

i can i get the Code to Pick up on What User im on and to Remove that User.

i am using nothing but text fields
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
removePerson = connection.prepareStatement(
"DELETE FROM Patient where PatientId=? and FirstName=? and LastName=? and Address=? and PhoneNumber?" );
 
david foley
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have used this Query


"DELETE History, Patient " +
" FROM " +
" History INNER JOIN Patient ON History.PatientId = Patient.PatientId " +
" WHERE (Patient.PatientId)= ?" );

This Works only when the Two Tables are Filled with Info.. E.G Patient Number 18 is also on History Table This Code Removes the Patient from Both Tablets, But if Patient 19 is only on Patient Table it will Tell me Patient Not Removed.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure all databases support deleting from views/joins. I would recommend to delete the data in two separate queries: first from the child table, then from the parent table. That is guaranteed to work in all databases out there.
 
reply
    Bookmark Topic Watch Topic
  • New Topic