<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Question2Answer Q&amp;A - Recent questions tagged q2a-category-experts</title>
<link>https://www.question2answer.org/qa/tag/q2a-category-experts</link>
<description>Powered by Question2Answer</description>
<item>
<title>SQL query help</title>
<link>https://www.question2answer.org/qa/60619/sql-query-help</link>
<description>I was trying to count the userpoints per category. The query works if I use a single level of category match. But if I try to get the points on subcategories too, the query gets too slow as it runs on uservotes table having thousands of rows. Is there a better way to do this? The current query is as follows with part of it coming from points update function in the core.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;$catfilter = &amp;quot; &amp;nbsp;and (userid_src.categoryid = b.categoryid or userid_src.categoryid &amp;nbsp;in &amp;nbsp;(&lt;br /&gt;
select categoryid from ^categories where parentid = b.categoryid)&lt;br /&gt;
or userid_src.categoryid &amp;nbsp;in &amp;nbsp;(&lt;br /&gt;
select categoryid from ^categories where parentid in (select categoryid from ^categories where parentid = b.categoryid)))&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
$query1 = &amp;quot;insert into ^catpoints (categoryid, userid, points) &amp;nbsp;(select &amp;nbsp;b.categoryid,#, &amp;quot;.&lt;br /&gt;
$calculations['aselecteds']['multiple'].&amp;quot;*(select &amp;nbsp;&amp;quot;.$calculations['aselecteds']['formula'].$catfilter.&amp;quot;)+&amp;quot;.&lt;br /&gt;
$calculations['avoteds']['multiple'].&amp;quot;*(select &amp;nbsp;&amp;quot;.$calculations['avoteds']['formula'].$catfilter.&amp;quot;)&lt;br /&gt;
as points&lt;br /&gt;
&amp;nbsp;from &amp;nbsp;^categories b) on duplicate key update ^catpoints.points=points&amp;quot;;</description>
<category>Q2A Core</category>
<guid isPermaLink="true">https://www.question2answer.org/qa/60619/sql-query-help</guid>
<pubDate>Fri, 03 Nov 2017 03:42:57 +0000</pubDate>
</item>
<item>
<title>SQL error in Category Experts plugin</title>
<link>https://www.question2answer.org/qa/60210/sql-error-in-category-experts-plugin</link>
<description>I'm getting the following error while the category Experts plugin update the points. Any help?&lt;br /&gt;
&lt;br /&gt;
PHP Question2Answer MySQL query error 1100: Table 'userid_src' was not locked with LOCK TABLES - Query: replace into qa_catpoints (categoryid, userid, points, netvotes, aselects) &amp;nbsp;select &amp;nbsp;b.categoryid,'34869', 80*(select &amp;nbsp;COUNT(*) AS aselecteds FROM qa_posts AS userid_src JOIN qa_posts AS questions ON questions.selchildid=userid_src.postid WHERE userid_src.userid='34869' AND userid_src.type='A' AND NOT (questions.userid&amp;lt;=&amp;gt;userid_src.userid) and (userid_src.categoryid = b.categoryid or userid_src.categoryid &amp;nbsp;in &amp;nbsp;(\nselect categoryid from qa_categories where parentid = b.categoryid)\nor userid_src.categoryid &amp;nbsp;in &amp;nbsp;(\nselect categoryid from qa_categories where parentid in (select categoryid from qa_categories where parentid = b.categoryid))))+2*(select &amp;nbsp;COALESCE(SUM(LEAST(5*upvotes,40)-LEAST(1*downvotes,10)), 0) AS avoteds FROM qa_posts AS userid_src WHERE LEFT(type, 1)='A' AND userid='34869' and (userid_src.categoryid = b.categoryid or userid_src.categoryid &amp;nbsp;in &amp;nbsp;(\nselect categoryid from qa_categories where parentid = b.categoryid)\nor userid_src.categoryid &amp;nbsp;in &amp;nbsp;(\nselect categoryid from qa_categories where parentid in (select categoryid from qa_categories where parentid = b.categoryid))))\nas points,\n(select &amp;nbsp;COALESCE(SUM(LEAST(5*upvotes,40)-LEAST(1*downvotes,10)), 0) AS avoteds FROM qa_posts AS userid_src WHERE LEFT(type, 1)='A' AND userid='34869' and (userid_src.categoryid = b.categoryid or userid_src.categoryid &amp;nbsp;in &amp;nbsp;(\nselect categoryid from qa_categories where parentid = b.categoryid)\nor userid_src.categoryid &amp;nbsp;in &amp;nbsp;(\nselect categoryid from qa_categories where parentid in (select categoryid from qa_categories where parentid = b.categoryid)))) as netvotes,\n(select &amp;nbsp;COUNT(*) AS aselecteds FROM qa_posts AS userid_src JOIN qa_posts AS questions ON questions.selchildid=userid_src.postid WHERE userid_src.userid='34869' AND userid_src.type='A' AND NOT (questions.userid&amp;lt;=&amp;gt;userid_src.userid) and (userid_src.categoryid = b.categoryid or userid_src.categoryid &amp;nbsp;in &amp;nbsp;(\nselect categoryid from qa_categories where parentid = b.categoryid)\nor userid_src.categoryid &amp;nbsp;in &amp;nbsp;(\nselect categoryid from qa_categories where parentid in (select categoryid from qa_categories where parentid = b.categoryid)))) as aselects\n from &amp;nbsp;qa_categories b</description>
<category>Plugins</category>
<guid isPermaLink="true">https://www.question2answer.org/qa/60210/sql-error-in-category-experts-plugin</guid>
<pubDate>Thu, 12 Oct 2017 13:21:17 +0000</pubDate>
</item>
</channel>
</rss>