Rechercher dans le manuel MySQL
B.4.4.7 Solving Problems with No Matching Rows
If you have a complicated query that uses many tables but that returns no rows, you should use the following procedure to find out what is wrong:
Test the query with
EXPLAIN
to check whether you can find something that is obviously wrong. See Section 13.8.2, “EXPLAIN Syntax”.Select only those columns that are used in the
WHERE
clause.Remove one table at a time from the query until it returns some rows. If the tables are large, it is a good idea to use
LIMIT 10
with the query.Issue a
SELECT
for the column that should have matched a row against the table that was last removed from the query.If you are comparing
FLOAT
orDOUBLE
columns with numbers that have decimals, you cannot use equality (=
) comparisons. This problem is common in most computer languages because not all floating-point values can be stored with exact precision. In some cases, changing theFLOAT
to aDOUBLE
fixes this. See Section B.4.4.8, “Problems with Floating-Point Values”.If you still cannot figure out what is wrong, create a minimal test that can be run with
mysql test < query.sql
that shows your problems. You can create a test file by dumping the tables with mysqldump --quick db_nametbl_name_1
...tbl_name_n
> query.sql. Open the file in an editor, remove some insert lines (if there are more than needed to demonstrate the problem), and add yourSELECT
statement at the end of the file.Verify that the test file demonstrates the problem by executing these commands:
shell> mysqladmin create test2 shell> mysql test2 < query.sql
Attach the test file to a bug report, which you can file using the instructions in Section 1.7, “How to Report Bugs or Problems”.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-no-matching-rows.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.