If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Access SQL to MySQL Inner Join Problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-03, 10:30
Xia Xia is offline
Registered User
 
Join Date: Nov 2003
Posts: 5
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
Reply With Quote
  #2 (permalink)  
Old 12-20-03, 15:41
omiossec omiossec is offline
Registered User
 
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/
--
Reply With Quote
  #3 (permalink)  
Old 12-21-03, 06:23
Xia Xia is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 12-22-03, 06:09
omiossec omiossec is offline
Registered User
 
Join Date: Jan 2003
Location: Paris, France
Posts: 320
You have no index on table 3
__________________
Olivier Miossec
--
http://www.lasso-developpeur.net/
--
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On