News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Help with SQL query error

Started by ormuz, January 06, 2017, 06:59:34 AM

Previous topic - Next topic

ormuz

this is the query

$request = $smcFunc['db_query']('','
SELECT
b.id_board, b.name as board_name, b.redirect, ' . ($rft_hide_topics ? 'h.id_topic, h.subject,' : '') . '
g.id_group, g.group_name, c.id_cat, c.name AS cat_name
FROM {db_prefix}boards AS b
INNER JOIN {db_prefix}categories AS c
' . ($rft_hide_topics ? 'LEFT JOIN {db_prefix}messages AS h ON (h.id_topic = ({array_int:id_topics})) ' : '') . '
INNER JOIN {db_prefix}membergroups AS g
WHERE id_group > {int:admin}',
array(
'admin' => 1,
'id_topics' => $rft_hide_topics,
)
);


and this is the error:

QuoteOperand should contain 1 column(s)
Line: 677

Any ideias?

Arantor

bestnow, what does that post even mean?

ormuz, you need to tell MySQL how to perform the joins, it needs to be told how to join categories to boards, or groups to anything.

ormuz


Arantor

What are you trying to do with this query?

I understand SQL just fine but I can't tell you how to rewrite this query without knowing more.

ormuz

it's from this "beta" mod...
http://www.simplemachines.org/community/index.php?topic=522114.msg3906944#msg3906944

the code says :D
Quote// Grab boards, categories, hidden topics, view permissions, usergroups

but from the error I understand that the logic is wrong and can't be done this way. Also from stackoverflow:
QuoteYour subquery is selecting two columns, while you are using it to project one column (as part of the outer SELECT clause). You can only select one column from such a query in this context.

Arantor

The SO answer is completely unrelated since it's talking about a subselect, which is not what this is doing,but you should report this to the mod author and let them deal with it.

Advertisement: