1

I have a request and I want to apply a cycle to it which will be held 11 times. How to do it ?

Insert into Mark (id_student,mark,date,id_discteacher)
Select student.id_student,'10','2019-05-09',id_discteacher from discipline_teacher 
JOIN discipline using(id_discipline)
join teacher using(id_teacher)
join group on class.id_group = discipline_teacher.group  
join student on student.group = group.id_group
where EXISTS (select * from discipline_teacher 
             join group on discipline_teacher.group = group.id_group
              join student on student.group = group.id_group
              JOIN discipline using(id_discipline)
              join teacher using(id_teacher)
              where discipline.title ='math' and teacher.id_teacher=1 and group.title ='2' and group.kurs ='А') 
              and discipline.title ='math' and teacher.id_teacher=1 and group.title ='2' and group.kurs ='А' and student.name = 'Anna' and student.last_name ='Makeeva';
2
  • 1
    What do you mean "apply a cycle to it which will be help 11 times? Commented May 19, 2019 at 15:58
  • @GordonLinoff I want the loop to work 11 times on this request. Commented May 19, 2019 at 16:02

1 Answer 1

2

If you want to multiply the number of records by 11, then use generate_series():

with t as (<your query here>)
select t.*
from t cross join
     generate_series(1, 11, 1);
Sign up to request clarification or add additional context in comments.

2 Comments

ERROR: WITH query "t" does not have a RETURNING clause LINE 20: from t cross join
Are you trying to put it in a function? Edit: I think I see. Just put the select part of your query in that part, to see if the result is what you expect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.