I need to write such a request, please, any help?
select id, parent, faq, (select count(*) from faq_table where parent = (select id from faq_questions) group by id) as reply from faq_table
This table stores questions and answers (for example, a question about frequently asked questions), and the answers get the value of the question identifier in the parent column. Ideally, I would also like to add a second column called par, where all questions get a value of 1.
how
id | parent | faq 19 | 0 | name a president of the US 20 | 19 | Bush 21 | 19 | Obama 22 | 0 | Can Canada win the WC match against the Lankan today 23 | 22 | Yes because Cheema is going to make a double today
In the resulting table from this query, I should get:
id | parent | faq | reply | par 19 | 0 | name a president of the US | 2 | 1 20 | 19 | Bush | 0 | 0 21 | 19 | Obama | 0 | 0 22 | 0 | Can Canada win the WC match against the Lankan today | 1 | 1 23 | 22 | Yes because Cheema is going to make a double today | 0 | 0
source share