Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
1.7k views
in Plugins by
There is a plugin for it but it does it individually.
Q2A version: 1.8.5

2 Answers

+4 votes
by
edited by
 
Best answer

The distinction between comment and answer is merely the value of the field type in the database table qa_posts. To convert all comments to answers do this:

UPDATE qa_posts SET type='A' WHERE type='C';

To convert just the comments for a particular question do this (replace 42 with the actual post ID of the question at hand):

UPDATE qa_posts SET type='A' WHERE parentid=42 AND type='C';


Edit: For converting comments on answers you can use a slightly modified version of the query for converting comments on questions that I posted in the comments. Change the post type from "Q" to "A" and also change the parent ID of the comment to the parent ID of the answer (i.e. the ID of its grandparent, which is the question).

UPDATE qa_posts c INNER JOIN qa_posts p ON c.parentid = p.postid SET c.type = 'A', c.parentid = p.parentid WHERE c.type = 'C' AND p.type = 'A';

If you want to convert comments for a particular post add a clause for the parent post ID:

... AND p.type = 'A' AND p.postid = 42;

by
+1
Of course they're not the same. Did you not read what I wrote in my answer? type='Q' is for CONVERTING COMMENTS ON QUESTIONS. type='A' is for CONVERTING COMMENTS ON ANSWERS.

If you want to convert comments on answers rather than questions YOU MUST USE THE LATTER INSTEAD OF THE FORMER.
by
+2
should that be?

UPDATE qa_posts c INNER JOIN qa_posts p ON c.parentid = p.postid SET c.type = 'A', c.parentid=p.parentid WHERE c.type = 'C' AND p.type = 'A';
by
+1
Ah, now I understand the problem. Yes, you're right, you need to update the parent ID of the comment to the parent ID of the answer (i.e. the question ID). Updated my answer.
by
+1
Yes, did work.. 20.000 comment is now answer, just add
AND length(c.content)>100
+3 votes
by
https://github.com/q2apro/q2apro-comment-to-answer/blob/master/q2apro-comment-to-answer-page.php

It's okay to do it one by one. Is it possible to do all of them?
by
maybe it can be done again for all comments in this plugin
...