MySQL Forums
Forum List  »  Connector/Python

LEFT JOIN give different result in PhpMyAdmin and Python code
Posted by: Alexis MARTINI
Date: August 06, 2018 08:31AM


I am quiet new to this forum, but didn't find out some answer about this problem.

I get information from a first table (Event) in order to know the running actions. And for those production tasks I want to know the quantities to be done from another table. So I do a LEFT JOIN in order to complet the first table with information from the second.

here the code tested in PhpMyAdmin:
"SELECT *, MAX(Ev1.`Horodatage`) AS LastAction FROM ( SELECT `Event`.`Sequence`, `Horodatage`, `USER_ID`, `Event`, `Multi`, `D_OF`.`Q_ini` FROM `Event` LEFT JOIN `D_OF` ON `Event`.`Sequence`=`D_OF`.`Sequence` ORDER BY `Horodatage` DESC ) AS Ev1 GROUP BY Ev1.`Sequence` DESC HAVING Ev1.`Event` = 0 "

It give me 2 lines in results. Which is correct according to the data.

When I copy and past the same query in Python code, the result is 11 lines. I have as many resultats than lines in my second table!
When geting out the "LEFT JOIN" the result is good, but do not have my last information ...
What's wrong with my query?
Is there a issu with the connector? I use Python 2.7 and MySQLdb module as interface.
MySQL is in version 5.7.

For moment the only way to go one is to make a loop on the result and add quantities from an other query. Not realy nice!


Options: ReplyQuote

Written By
LEFT JOIN give different result in PhpMyAdmin and Python code
August 06, 2018 08:31AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.