mysql - 如何在mysql中使用LEFT JOIN

标签 mysql

我的代码出现错误,希望能提供一些帮助。这只是我尝试学习的第一天,所以请尽可能简单,谢谢

#1064 - You have an error in your SQL syntax; check the manual that 
corresponds to your MariaDB server version for the right syntax to use 
near 'FROM specials LEFT JOIN products_description LEFT JOIN products 
WHERE special' at line 2

SELECT specials.specials_id, specials.products_id,specials_new_products_price, products.products_image,  products.products_price,products.products_image, products.products_quantity,products.products_model,products_description.products_name,products_description.products_description,
FROM specials 
LEFT JOIN  products_description
LEFT JOIN  products
WHERE specials.products_id = products.products_id AND specials.products_id = products_description.products_id AND products.products_quantity>0

最佳答案

检查这个语法

SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name=table2.column_name;

例子

SELECT specials.specials_id, specials.products_id,specials_new_products_price, products.products_image,  products.products_price,products.products_image, products.products_quantity,products.products_model,products_description.products_name,products_description.products_description
FROM specials 
LEFT JOIN  products on specials.products_id = products.products_id
LEFT JOIN  products_description on specials.products_id = products_description.products_id
WHERE products.products_quantity>0

希望这能行得通

关于mysql - 如何在mysql中使用LEFT JOIN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40287105/

相关文章:

php - 在mysql文件中加载数据在php脚本中不起作用

MySQL:为什么 DELETE 比 INSERT 更占用 CPU?

mysql - 从 WordPress 数据库中提取数据 - 未知格式

php - 从 print_r 输出中删除数组 ( [0] =>

php - 通过 PHPSpreadsheet 在 codeigniter 中使用 PHP 上传 2 个 excel 文件

mysql - OperationalError : (1054, "Unknown column ' time_table.id' in 'field list' ")

mysql - 在数据库中拥有标志是否比每次查询表更好?

mysql - 如何在MySQL中分割逗号分隔的记录字符串并按顺序排列?

php - 使用php将数据插入数据库的问题

mysql - SQL如何输出数据出现的次数?