Scene:
There is A learning form A record the user number and learning content number
The table a (userid, lecid)
There is a table B records the user classification, contain the user number and classification number
Table b (userid, qid)
There is a table c recorded the relationship table of users and other users, including user number and is associated with the user number
Table c (userid, ruid)
Now hope that through classified number qid in table b, searching out all in table b userid and retrieve the associated userid and table b in table c ruid learning records in the table a
thank you
CodePudding user response:
Select b.u serid, a. ceid from table a and table b, table c where b.q qid id=queries and b.u serid=c.u serid and c.u serid=a.u serid
CodePudding user response:
SELECT * b.o id, a.The FROM b - now hope that through classified number qid in table b, searching all the userid in table b INNER JOIN c ON b.u serid=c.u serid - and retrieve the associated userid and table b in table c INNER JOIN a uid=ON c.r a.u serid - ruid in learning records in the table a CodePudding user response:
refer to the second floor ZJCXC response: SELECT * b.o id, a.The FROM b - now hope that through classified number qid in table b, searching all the userid in table b INNER JOIN c ON b.u serid=c.u serid - and retrieve the associated userid and table b in table c INNER JOIN a uid=ON c.r a.u serid - ruid in learning records in the table a The classification condition qid assignment in table b: SELECT * b.o id, a.The FROM b - now hope that through classified number qid in table b, searching all the userid in table b INNER JOIN c ON b.u serid=c.u serid - and retrieve the associated userid and table b in table c INNER JOIN a uid=ON c.r a.u serid - ruid in learning records in the table a Where b.q id=? This result is not I want I hope the final figures is for all the people in table b, and table b in the associated table c all the people in the study records in the table a CodePudding user response:
Provide test data and results CodePudding user response:
Sorry, the first two days is out, The reference 4 floor ZJCXC reply: provide test data and results There is A learning form A record the user number and learning content number The table a (userid, lecid) 1, 1 1, 2, 1, 3 2, 1 3, 2 3, 4 4, 1 4, 3 5, 1 5, 2 There is a table B records the user classification, contain the user number and classification number Table b (userid, qid) 1, 2, 2, 2 3, 1 4, 3 There is a table c recorded the relationship table of users and other users, including user number and is associated with the user number Table c (userid, ruid) 1, 2, 1, 5 2, 3 3, 1 If the input table b qid=2, hope to get the table a output is 1, 1 1, 2, 1, 3 2, 1 5, 1//because 1 associated with 5, 2 If the input qid=3 3, 2 3, 4 1, 1//because 3 associated with 1 1, 2, 1, 3 CodePudding user response:
The reference 4 floor ZJCXC reply: provide test data and results The first inner join there is no problem, is limiting the amount of people in classification Should be joined the classification of the people related to the second of all learning, with inner words, not only not associated with more people CodePudding user response:
If the input table b qid=2, hope to get the table a output is 1, 1 1, 2, 1, 3 2, 1 5, 1//because 1 associated with 5, 2 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1 associated with 5 by 1, 2, 1, 5 The relationship? If so, then the qid table b=2, corresponding with two userid Table b (userid, qid) 1, 2, 2, 2 - & gt; Why don't you find 1, go to 2? CodePudding user response:
refer to 7th floor ZJCXC response: if the input table b qid=2, hope to get the table a output is 1, 1 1, 2, 1, 3 2, 1 5, 1//because 1 associated with 5, 2 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1 associated with 5 by 1, 2, 1, 5 The relationship? If so, then the qid table b=2, corresponding with two userid Table b (userid, qid) 1, 2, 2, 2 - & gt; Why don't you find 1, go to 2? I'm sorry, really wrong, if qid=2, the results 1, 1 1, 2, 1, 3 2, 1 5, 1//because 1 associated with 5, 2 Because, 2/3/2 associated number 3 3, 4 Is the need to this result, thank you CodePudding user response:
SELECT a. * FROM a, ( The SELECT b.u serid FROM b WHERE b.q id=2 The UNION The SELECT c.r uid FROM b, c WHERE b.q id=2 AND b.u serid=c.u serid ) x WHERE x.u serid=a.u serid CodePudding user response:
references 9 f ZJCXC response: SELECT a. * FROM a, ( The SELECT b.u serid FROM b WHERE b.q id=2 The UNION The SELECT c.r uid FROM b, c WHERE b.q id=2 AND b.u serid=c.u serid ) x WHERE x.u serid=a.u serid Tested this shouldn't be a problem, but related to the actual project, still have some questions, There is a table c recorded the relationship table of users and other users, including user number and is associated with the user number, this relationship has a relationship name, which stored in the name of the serial number Table c (userid, ruid, RXH) 1, 2, 1 1, 5, 2 2, 3, 2 3, 1, 3 The table d is representing table RXH rname 1 the manager 2 the boss 3 the group leader Finally, classification qid=1 will be able to get the data above, the corresponding people also want be retrieved name Thank you CodePudding user response:
Not related directly to the default for the 'I' CodePudding user response:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull