MySQL 5.1 リファレンスマニュアル :: B Errors, Error Codes, and Common Problems :: B.1 Problems and Common Errors :: B.1.5 Query-Related Issues :: B.1.5.7 Solving Problems with No Matching Rows
« B.1.5.6 Deleting Rows from Related Tables

B.1.5.8 Problems with Floating-Point Comparisons »
Section Navigation      [Toggle]
  • B.1.5 Query-Related Issues
  • B.1.5.1 Case Sensitivity in Searches
  • B.1.5.2 Problems Using DATE Columns
  • B.1.5.3 Problems with NULL Values
  • B.1.5.4 Problems with Column Aliases
  • B.1.5.5 Rollback Failure for Non-Transactional Tables
  • B.1.5.6 Deleting Rows from Related Tables
  • B.1.5.7 Solving Problems with No Matching Rows
  • B.1.5.8 Problems with Floating-Point Comparisons

B.1.5.7. Solving Problems with No Matching Rows

If you have a complicated query that uses many tables but that doesn't return any rows, you should use the following procedure to find out what is wrong:

  1. Test the query with EXPLAIN to check whether you can find something that is obviously wrong. See 項6.2.1. 「EXPLAINを使用して、クエリを最適化する」.

  2. Select only those columns that are used in the WHERE clause.

  3. Remove one table at a time from the query until it returns some rows. If the tables are large, it's a good idea to use LIMIT 10 with the query.

  4. Issue a SELECT for the column that should have matched a row against the table that was last removed from the query.

  5. If you are comparing FLOAT or DOUBLE columns with numbers that have decimals, you can't 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 the FLOAT to a DOUBLE fixes this. See 項B.1.5.8. 「Problems with Floating-Point Comparisons」.

  6. If you still can't figure out what's 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_name tbl_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 your SELECT 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 項1.7. 「質問またはバグの報告」.

Copyright © 1997, 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices
Top / Previous / Next / Up / Table of Contents
© 2010, Oracle Corporation and/or its affiliates