Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    5

    Unanswered: Access SQL to MySQL Inner Join Problem

    Here is a Access SQL query for use with a MySQL database:

    $sql = 'SELECT table1.*, table2.*, table3.* FROM table3 INNER JOIN (table1 INNER JOIN table2 ON table1.ID_No = table2.ID_No) ON table3.Cust_No = table2.Cust_No WHERE (((table1.Name) Like "%Hofman%")) ORDER BY table1.Name LIMIT 0,10';

    I can't get this working using Apache / PHP, the page just keeps loading and slows my PC down tremendously. It has no problems with a query with just two tables out of three.

    Any ideas what's wrong?

    Thanks

  2. #2
    Join Date
    Jan 2003
    Location
    Paris, France
    Posts
    320
    try to use explain your query in mysql client to see what is wrong.
    Olivier Miossec
    --
    http://www.lasso-developpeur.net/
    --

  3. #3
    Join Date
    Nov 2003
    Posts
    5
    Here is the Explain Dump:

    table type possible_keys key key_len ref rows Extra
    table3 ALL Cust_No NULL NULL NULL 125
    table1 ref ID_Cust,Cust_No,ID_No Cust_No 4 table3.Cust_No 3571 Using where
    table2 ref ID_No ID_No 6 table1.ID_No 1 Using where

    What can I learn from this? Something is wrong with table 3? It has a possible key, then why doesn't it use it?

    Also, why is the suggested nr of rows is completely wrong?

    Thanks for the help

  4. #4
    Join Date
    Jan 2003
    Location
    Paris, France
    Posts
    320
    You have no index on table 3
    Olivier Miossec
    --
    http://www.lasso-developpeur.net/
    --

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •