Hello. There is a need to create a complex query (procedure). No difference. There are 2 key related tables. journal_field_data with the key journal_record_id and Journal_Records with the key id . Also in Journal_Records there is a key JOURNAL_ID and JOURNAL_TABLE_ID . The essence of the task itself is that in the html code there is a table with a table nested in it. I needed to pull some of the fields from the nested table into the main one. In order that I could view the previously entered data, I need to rewrite the old data in the new fields in the database. So far I have figured out how to make 2 samples for the conditions of the final query (procedure). Here is how I do:
select * from journal_field_data where journal_record_id in (select id from Journal_Records where journal_id = 10286 and journal_table_id = 1001) select * from journal_field_data where journal_record_id in (select id from Journal_Records where journal_id = 10286 and journal_table_id = 1) With the first query, I select the data in the nested table as it looked before. And I need part of the records (based on the condition on the FIELD_NAME field) to change journal_record_id to the desired journal_record_id from the second query I journal_record_id . So far, I do not understand how to do it. The algorithm is complicated. What I described can be implemented at all. If so then who knows tell me how this can be done. I would be very grateful if there are examples. Thanks in advance.