We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Help with query

Development and Programming

w84me's avatar
w84me
95 posts
15 years ago
w84me's avatar w84me

Hi all,

I have this query

{exp:query sql="
SELECT 
exp_channel_data.field_id_16 as badge,
exp_channel_data.field_id_29 as image,
exp_channel_titles.url_title as url_title
FROM 
exp_channel_data
INNER JOIN exp_channel_titles ON exp_channel_data.channel_id = exp_channel_titles.channel_id 
WHERE 
exp_channel_data.field_id_19 = '<?php echo $ah; ?>'
OR
exp_channel_data.field_id_18 = '<?php echo $type; ?>' 
ORDER BY exp_channel_data.field_id_16
"}

My problem is that it fetches the entries multiplied by the total count.

for example if I have one entry in channel it brings 2 times the entry if I have two entries 2 times the two entries (entry1,entry2,entry1,entry2) and so on..

Where is the problem?

Thank you in advance.

       
the3mus1can's avatar
the3mus1can
426 posts
15 years ago
the3mus1can's avatar the3mus1can

Try adding DISTINCT(exp_channel_titles.entry_id) to the query.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.