1

i'm really confused in how to do this in mysql and if it's possible at all. I have a table where i need to select articles which have id = idi:

$query->select('title, id, idi, introtext');
$query->from('#__content');
$query->where('idi = ' . $id);

So, now component shows main article ( id ) and extra articles which has same IDI as ID.

__content table

ID IDI
0    0
1    0
2    1
3    1

So, article with ID 1 will have extra articles with ID 2,3 because IDI is 1. ID=IDI

And now i need to get extra articles voting_results from table ratings where votings_results ID are equal to #__content id.

__ratings table

ID voting_result1
0           55
1          123
2           64          <--
3           42          <--
4

1 に答える 1

0

You can do something like this:

select sum(voting_result1) as "Total" from #__ratings table 
where ID = 1 or 
ID in (select IDI from #__content table where IDI = 1)
于 2012-10-08T19:46:02.497 に答える