views:

24

answers:

1

I am trying to join 4 tables but having issues. my code is listed below.

The error I recieve is

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON advancedcatalog_font_type.id = advancedcatalog_dimensions.font_type_id) LEFT ' at line 6

advancedcatalog_dimensions

id         |letter_id    |    font_type_id     |  font_size_id  |   dimensions   |   LED
----------------------------------------------------------------------------------------------
  1        |             |                     |                |                |
  2        |             |                     |                |                |
  3        |             |                     |                |                |
  4        |             |                     |                |                |

advancedcatalog_font_size

id         |font_size    |   
--------------------------
  1        |             |   
  2        |             | 
  3        |             |   
  4        |             |  

advancedcatalog_font_type

id         |font_name    |    
--------------------------
  1        |             | 
  2        |             |   
  3        |             |   
  4        |             |      

advancedcatalog_letter

id         |casing       |    letter           |  
------------------------------------------------
  1        |             |                     |  
  2        |             |                     |
  3        |             |                     |     
  4        |             |                     |      

Query that works:

   SELECT advancedcatalog_letter.letter, 
          advancedcatalog_dimensions.dimensions, 
          advancedcatalog_font_type.font_name       
     FROM (advancedcatalog_dimensions
LEFT JOIN advancedcatalog_letter ON advancedcatalog_dimensions.letter_id = advancedcatalog_letter.id) 
LEFT JOIN advancedcatalog_font_type ON advancedcatalog_font_type.id = advancedcatalog_dimensions.font_type_id
    LIMIT 0 , 400

Query that does NOT work:

   SELECT advancedcatalog_letter.letter, 
          advancedcatalog_dimensions.dimensions, 
          advancedcatalog_font_type.font_name       
     FROM (advancedcatalog_dimensions
LEFT JOIN advancedcatalog_letter ON advancedcatalog_dimensions.letter_id = advancedcatalog_letter.id) 
LEFT JOIN (advancedcatalog_font_type ON advancedcatalog_font_type.id = advancedcatalog_dimensions.font_type_id)
LEFT JOIN advancedcatalog_font_size ON advancedcatalog_font_size.id = advancedcatalog_dimensions.font_size_id
+1  A: 

advancedcatalog_dimensions.font_size_id does not exist and you are referencing it in your second query.

RedFilter
my apologize. that was a error on my part. font_size_id does exist in the table
numerical25
It's probably your bracketing then - remove all brackets.
RedFilter
You are right. Thanks alot. I was falling a tutorial that used the parenthesis so I figure that is how it was done. But I wonder why it works with 2 left joins but not we 3.
numerical25