Answer the question
In order to leave comments, you need to log in
How to write a SQL query for this case?
Good morning! It is necessary to write an SQL query for these tables in the
connection napravlenie ->history HASONE, the connection history->napravlenie hasMany
and the connection between checkinganaliz->napravlenie HASMANY.
I want to recycle data between history->napravlenie only hasOne, napravlenie ->checkanaliz hasMany.
For example, the type of data:
I need only 1 direction in the database, i.e. in checkAnaliz, I need to put down the id records of the first direction and then delete the repeated directions of the history case.
That is, the form should take this
Answer the question
In order to leave comments, you need to log in
It seems to me that your task can be formulated differently:
1. In the checkanaliz table, replace the value of the id_napravlenie field with id_history from the napravlenie
table 2. Delete records in which id <> id_history from the napravlenie table
Maybe this will prompt you to a decision, do not write a query for you really want.
First, update the records in the checkanaliz table:
update checkanaliz set id_napravlenie = 1 where id_napravlenie = 2
delete from napravlenie where id = 2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question