views:

808

answers:

1

Hiya,

I have another problem with sql queries running as I expect in PHPMyadmin, but when I add the sql to my PHP script, it does not work as expected.

This is the formula of my sql:

select DISTINCT 
        table1.id AS ID,
        table1.title AS Title,
        table1.startdate AS StartDate,
        table1.enddate AS EndDate,
        table1.type AS Type,
        table2.image AS ImagePath
        table3.colour AS Colour
        FROM table1
        table1 LEFT JOIN table2 table2 ON table1.id = table2.id
               LEFT JOIN table3 table3 ON table1.id = table3.id
        WHERE Type LIKE 'E' AND StartDate >= DATE(NOW()) AND EndDate >= DATE(NOW()) 
        ORDER BY StartDate ASC

I get 23 results returned in PHPMyadmin which is correct - but when I add the sql to my PHP and run it, I get duplicate entries and I am not sure what I am doing wrong.

Any ideas?

+1  A: 

It would appear that it is not the SQL that is the issue - We have inherited a drupal site and there is a function that seems to executing more than once, causing the sql to be executed multiple times.

Better get digging to find out the issue!

Thanks anyway guys!