Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delete multiple records using array in postgresql

Tags:

postgresql

I need a procedure for delete multiple rows in multiple tables by passing array set of values in parameters

Consider 3 tables:

student_master(id,student_name);
subject_master(id,subject_name);
marks(id,student_id,student_id,subject_id,marks)

here in parameter for e.g student id will be: a['1','3','7','15']

What is the procedure for this criteria?

like image 681
dinesh danny Avatar asked Dec 13 '22 23:12

dinesh danny


1 Answers

If your student_id s are integer or bigint then use without quote:

delete from marks
where student_id = ANY(Array [1,3,7,15])
returning student_id
like image 153
light souls Avatar answered Jan 09 '23 01:01

light souls