Php queries all the data in table an of the mysql database, and then looks up the table B that belongs to table A with the most data.

this is a function of asking and answering questions
questions asked by users in Table A
questions answered by users in Table B

Table An is the only question corresponding to ID,
Table B PID corresponds to Table An ID users answer which question PID is which question ID
now need to output popular answer this function, that is, to pass which question is answered more times, in order to order
it is done by yourself, but it is too stupid and consumes performance. I hope you can help

.
Feb.28,2021

for example, table An is: questions, B, table is answers

then SQL is

select a.id, a.title, count(b.pid) as answer_count  from questions a, answers b where a.id=b.pid group by b.pid order by answer_count DESC;
Menu