Home > Back-end >  Multi-table LianZha
Multi-table LianZha

Time:12-17

A total of 3 tables, the project list (there are four positions and project id field), the user table (user id and user name), intermediate table (project id, user id and position (including position manager on behalf of the 1, team leader for 2, representatives of 3, team members on behalf of the 4)),
The question now is the associative table, and then reflect the data table in the middle, first of all, this is just the absence of back-end operate front end to reflect, just in order to find out the data into the middle of table
Project list of each position=user table user name field
Project table project id field=the table in the middle of the project id field
User table user id field=the table in the middle of the user id field
Another is how to deal with the middle table to a position within the
Great god please help it, how do I write the SQL, studied several days nothing

CodePudding user response:

Did not understand your need, is you need to link to check? Or check + insert?

CodePudding user response:

Look at this request, is to think through the project table and the user table to generate the intermediate table
For example
 insert into table in the middle (audit_id, user_id, audit_post) 
The select a.a udit_id,
B.u ser_id,
The case when a.a udit_duty=b.n ame then '1'
The when a.a udit_headman=b.n ame then '2'
The when a.a udit_judge=b.n ame then '3'
The else '4'
End
From the project table a, user table b
Where b.n ame in (a.a udit_duty, a.a udit_headman, a.a udit_judge, a.a udit_menber);
  • Related