1
DELETE student_info,admission_details,parent_info
FROM student_info LEFT JOIN admission_details
ON student_info.student_id = admission_details.student_id 
LEFT JOIN parent_info ON admission_details.student_id = parent_info.student_id 
WHERE student_info.student_id = 234

I am getting error in this code using Postgres 9.1. I used this query for the deleting the 3 tables data.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user3493933
  • 21
  • 1
  • 3
  • You cannot specify more than one table in the `DELETE` part –  Apr 03 '14 at 13:25
  • I think you actually want `DELETE ... USING`, but unfortunately you can only do that with a simple `WHERE` clause (i.e. using an inner join). You have to do a further outer join on `student_info`. Pretty sure there are examples in the manual under delete ... using. – Craig Ringer Apr 04 '14 at 01:49

1 Answers1

1

You can't delete from more than one table at a time. You have to write individual delete statement for each table. You can use joins if you need.

This link may help you solve the problem. Here there is an accepted solution. It uses transaction for deleting from multiple tables.