alex_globe Posted January 16, 2009 Share Posted January 16, 2009 Hey there, I made a request lately, which seemed good, but after some testing I got some really odd results. Obviously, there's something I misunderstand about that kind of request and I wanted to know if anyone could help me with it. Here's the request : SELECT DISTINCT sp.No_Sequence_Production, ste.No_Type_Extrusion, np.Numero, ste.OuiNon, ste.A_Produire, sp.Status_Produit FROM sequence_production_piece AS spp INNER JOIN sequence_production AS sp ON spp.No_Sequence_Production = sp.No_Sequence_Production INNER JOIN sequence AS s ON sp.No_Sequence = s.No_Sequence INNER JOIN client AS c ON s.No_Client = c.No_Client INNER JOIN sequence_type_extrusion AS ste ON s.No_Sequence = ste.No_Sequence INNER JOIN pince AS p ON spp.No_Sequence_Production_Piece = p.No_Sequence_Production_Piece INNER JOIN numero_pince AS np ON p.No_Numero_Pince = np.No_Numero_Pince INNER JOIN type_extrusion AS te ON spp.No_Type_Extrusion = te.No_Type_Extrusion INNER JOIN extrusion AS e ON spp.No_Extrusion = e.No_Extrusion WHERE sp.Status_Produit = 7 AND ste.OuiNon = 1 AND ste.A_Produire = 1 GROUP BY ste.No_Type_Extrusion ORDER BY np.Numero ASC It gives me four results. Let's call 'em a, b, c and d. My program shows all these results in a list and I have the possibility to pick one and add it to another list. When I do so, I want the item I picked to disappear from the original list, so for each one I specify a condition to exclude the item, basing on it's id. Just like this : AND NOT (spp.No_Sequence_Production = 7297 AND ste.No_Type_Extrusion = 4) It works well to some point, as let's say "b" isn't in the results anymore, just as it's supposed to be. However, I get a new result, "e", which simply come out of nowhere. After some checking, it appears it has the right criterias. And if I take "a" from my initial list, a "f" will take it place and so on ... Now why hasn't it shown in the first results and how could my simple condition make it suddenly appear ? If anyone could help, I'm really struck here. I'd say there's something I missed in how to structure my query ... Link to comment https://forums.phpfreaks.com/topic/141107-mysql-odd-results/ Share on other sites More sharing options...
Mchl Posted January 16, 2009 Share Posted January 16, 2009 NOT (spp.No_Sequence_Production = 7297 AND ste.No_Type_Extrusion = 4) is equal to (spp.No_Sequence_Production != 7297 OR ste.No_Type_Extrusion != 4) (de Morgan's law) Check if this is what you actually want. Perhaps you want (spp.No_Sequence_Production != 7297 AND ste.No_Type_Extrusion != 4) Link to comment https://forums.phpfreaks.com/topic/141107-mysql-odd-results/#findComment-738543 Share on other sites More sharing options...
alex_globe Posted January 16, 2009 Author Share Posted January 16, 2009 You're sure about that ? 'Cause initially I made my condition like this : AND (spp.No_Sequence_Production != 7297 AND ste.No_Type_Extrusion != 4) But it actually got me rid of every 7297 and every 4 (in their respective columns) of the recordset. While of course I only want to get rid of 7297 when the other column is at 4. If what you say is right ... my actual criteria should've done the same I think ... ? In any case, thanks for trying to help ^^ Link to comment https://forums.phpfreaks.com/topic/141107-mysql-odd-results/#findComment-738619 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.