Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

LEFT JOIN give different result in PhpMyAdmin and Python code (no replies)

$
0
0
Hi,

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!

Alexis MARTINI

Viewing all articles
Browse latest Browse all 384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>