username ikisindede aynı olduğu için tekrarlaması normal.
Group by yada distinc ile dene bakalım.
SELECT p.id as 'pollsID',c.id as 'contentID', c.title as 'contentTitle',p.title as 'pollsTitle' FROM forum_content as c INNER JOIN forum_polls as p ON c.username=p.username WHERE c.username='{$user->username}' GROUP BY p.id,c.idOlmazsa şunu dene.
SELECT content.*,polls.* FROM (c.id as 'contentID', c.title as 'contentTitle',c.username FROM forum_content as c WHERE c.username='{$user->username}') as content INNER JOIN (SELECT p.id as 'pollsID',p.title as 'pollsTitle',p.username FROM forum_polls as p WHERE p.username='{$user->username}') as polls ON content.username=polls.username
İlk sorgu yine tekrarlıyor. İkinci sorgu ise hata veriyor. DISTINC ve GROUP BY seçeneklerini bende denedim. Sonuç şöyle:
Array
(
[0] => Array
(
[pollsID] => 1
[contentID] => 7
[contentTitle] => Tanışalım
[pollsTitle] => Yeni Sitemiz
)
[1] => Array
(
[pollsID] => 1
[contentID] => 169
[contentTitle] => Video istek
[pollsTitle] => Yeni Sitemiz
)
[2] => Array
(
[pollsID] => 1
[contentID] => 170
[contentTitle] => Program İstek
[pollsTitle] => Yeni Sitemiz
)
[3] => Array
(
[pollsID] => 1
[contentID] => 171
[contentTitle] => Oyun İstek
[pollsTitle] => Yeni Sitemiz
)
)
Type: Array
Last Query [17]: SELECT p.id as 'pollsID',c.id as 'contentID', c.title as 'contentTitle',p.title as 'pollsTitle' FROM forum_content as c INNER JOIN forum_polls as p ON c.username=p.username WHERE c.username='Administrator' GROUP BY p.id,c.id
Last Function Call: $db->query("SELECT p.id as 'pollsID',c.id as 'contentID', c.title as 'contentTitle',p.title as 'pollsTitle' FROM forum_content as c INNER JOIN forum_polls as p ON c.username=p.username WHERE c.username='Administrator' GROUP BY p.id,c.id")
Last Rows Returned: 4İkinci sorgunun hatası:
Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''contentID', c.title as 'contentTitle',c.username FROM forum_content as c WHERE '