mysql  5  个表select distinct Product.id, Product.name from products as Product left join products_categories on (Product.id=products_categories.product_id) left join categories AS Category on (products_categories.category_id = categories.id) where Product.name LIKE '%da4b9237bacccdf19c0760cab7aec"a8359010b0%' or Maker.name LIKE '%da4b9237bacccdf19c0760cab7aec"a8359010b0%' or Category.name LIKE '%da4b9237bacccdf19c0760cab7aec"a8359010b0%' order by Product.id asc limit 10 offset 0
1054: Unknown column 'Maker.name' in 'where clause'各位大侠,小弟初来乍到..还望多指点一二.
还有 就是.....救命啊!!!!!!!!!!!!!!!!!!!!!!!!哪在哪里??在线等

解决方案 »

  1.   

    我试了2表查询 select distinct Product.id, Product.name from products as Product left join products_makers on (Product.id=products_makers.product_id) left join makers AS Maker on (products_makers.maker_id = Maker.id) where Product.name LIKE '%0ade7c2cf97f75d009975f4d720d1fa6c19f4897%' or Maker.name LIKE '%0ade7c2cf97f75d009975f4d720d1fa6c19f4897%' order by Product.id asc limit 10 offset 0这样是成功的。。3表的话,,。。写法错了吗??还请大家帮帮我
      

  2.   

    你的Maker表没有在连接中,怎么会在WHERE中出现?你测试过的SQL语句中,出现了MAKRE表
      

  3.   

    要在WHERE中出现,必须在FROM OR JOIN中出现表名
      

  4.   

    try:
    select distinct Product.id, Product.name from products as Product left join products_categories on (Product.id=products_categories.product_id) left join categories AS Category on (products_categories.category_id = categories.id) 
    left join makers AS Maker on (products_makers.maker_id = Maker.id)
    where Product.name LIKE '%da4b9237bacccdf19c0760cab7aec"a8359010b0%' or Maker.name LIKE '%da4b9237bacccdf19c0760cab7aec"a8359010b0%' or Category.name LIKE '%da4b9237bacccdf19c0760cab7aec"a8359010b0%' order by Product.id asc limit 10 offset 0
      

  5.   

    try: 
    select distinct Product.id, Product.name from products as Product left join products_categories on (Product.id=products_categories.product_id) left join categories AS Category on (products_categories.category_id = categories.id) 
    left join makers AS Maker on (products_makers.maker_id = Maker.id) 
    where Product.name LIKE '%da4b9237bacccdf19c0760cab7aec"a8359010b0%' or Maker.name LIKE '%da4b9237bacccdf19c0760cab7aec"a8359010b0%' or Category.name LIKE '%da4b9237bacccdf19c0760cab7aec"a8359010b0%' order by Product.id asc limit 10 offset 0