Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 错误代码:1054。未知列';s、 产品标识';在';关于第'条;错误代码:1054。未知列';s、 产品标识';在';关于第'条;_Mysql_Mysql Error 1054 - Fatal编程技术网

Mysql 错误代码:1054。未知列';s、 产品标识';在';关于第'条;错误代码:1054。未知列';s、 产品标识';在';关于第'条;

Mysql 错误代码:1054。未知列';s、 产品标识';在';关于第'条;错误代码:1054。未知列';s、 产品标识';在';关于第'条;,mysql,mysql-error-1054,Mysql,Mysql Error 1054,我在MySQL中有一个错误:错误代码:1054。“on子句”中的未知列“s.Product\u id” 它出现在: SELECT c.customer_ID, p.Product_id, p.Product_price, s.Items_quantity, (p.Product_price * s.Items_quantity) AS total FROM Products p LEFT JOIN Shopping_list s ON p.Product_id = s.Product_id LE

我在MySQL中有一个错误:
错误代码:1054。“on子句”中的未知列“s.Product\u id”

它出现在:

SELECT c.customer_ID, p.Product_id, p.Product_price, s.Items_quantity, (p.Product_price * s.Items_quantity) AS total FROM Products p LEFT JOIN Shopping_list s ON p.Product_id = s.Product_id LEFT JOIN Customer_sign_in c ON c.customer_ID = s.customer_ID LIMIT 0, 50000

有人知道为什么会这样吗?

你应该使用左连接

select c.customer_ID, p.Product_id, p.Product_price, s.Items_quantity,
    (p.Product_price * s.Items_quantity) as total from Products p LEFT JOIN Shopping_list s ON p.Product_id = s.Product_id LEFT JOIN Customer_sign_in c ON c.customer_ID = s.customer_ID;

您确定有表
购物清单
和名为
产品id
的列吗

如果没有,请创建列并重试。

如果存在,请删除数据库shopmeout;
drop database if exists shopmeout;
create database shopmeout;
use shopmeout;
drop table if exists Customer_sign_in;

CREATE TABLE Customer_sign_in (
    customer_ID INT (50) not null,
    Name_customer varchar(255) not null,
    Credit_card BIGINT(100) not null,
    Password_cust TEXT(150) not null,
    Email_cust TEXT(50) not null,
    primary key (customer_ID)
);
insert into Customer_sign_in values( 19867889, 'Stefan Darescu', 9018783269173917, 'personalcomputer84', 'stefandarescu@gmail.com');
insert into Customer_sign_in values( 11958178, 'Mogens Hemming', 5090180120973782,'masadebiliard4', 'mogenshemming@yahoo.com');
insert into Customer_sign_in values( 52562523, 'Viggo Kristian', 9015908218093698,'asawece', 'viggokristian@gmail.com');
insert into Customer_sign_in values( 42515323, 'Asbjørn Hjalmar', 0198490128761903,'esrjgads', 'asbjornhjalmar@hotmail.com');
insert into Customer_sign_in values( 69723642, 'Rasmus Bjarne', 9180583647839793,'Sgsyhdfs', 'rasmusbjarne@outlook.com');

CREATE TABLE Products (
    Product_id INT(150) not null,
    Product_name VARCHAR(100) not null,
    Product_price DECIMAL(6,2) not null,
    Deduction_price INT(50) not null,
    Deadline DATE not null,
    PRIMARY KEY (Product_id)
);
insert into Products values( 509687, 'Plain Flower', 59.46, 10, '2013-05-30');
insert into Products values( 485901, 'Cow Milk', 17.85, 12, '2013-04-18');
insert into Products values( 908571, 'Kærgården', 131.75, 8, '2013-04-07');
insert into Products values( 432612, 'Chicken Eggs', 27.57, 9, '2013-03-31');
insert into Products values( 853235, 'Pepsi Cherry', 25.11, 12, '2013-03-25');
insert into Products values( 357342, 'Spaghetti', 10.8, 5, '2013-03-20');
insert into Products values( 123563, 'Spaghetti sos', 22.4, 10, '2013-03-17');

delimiter //
CREATE TRIGGER first_trigger BEFORE UPDATE ON Products
FOR EACH ROW
BEGIN
 IF NEW.Product_price < 20 THEN
 SET NEW.Product_price = 15;
 ELSEIF NEW.Product_price > 140 THEN
 SET NEW.Product_price = 80;
 END IF;
END;//
delimiter ;
UPDATE Products set Product_price = 25 where Product_id = 509687;
UPDATE Products set Product_price = 22 where Product_id = 908571;

CREATE TABLE Recipes (
    Recipes_id INT (10) not null,
    Recipe_name CHAR (150) not null,
    Recipe_descrip TEXT(255) not null,
    primary key (Recipes_id)
);
insert into Recipes values( 513678, 'Pancakes', 'Crack the eggs into a blender, add the flour, milk and a pinch of sea salt, and blitz until smooth.');
insert into Recipes values( 867523, 'Spaghetti Bolognese', 'Heat the oil in a large, heavy-based saucepan and fry the bacon until golden over a medium heat.');

CREATE TABLE Shopping_list (
    Shopping_list_id INT (50) not null,
    customer_ID INT (50) not null,
    Items_quantity INT (50) not null,
    primary key (Shopping_list_id),
    foreign key (customer_ID)
        REFERENCES
    Customer_sign_in (customer_ID)
);
insert into Shopping_list values( 14081869, 19867889, 15);
insert into Shopping_list values( 15163266, 11958178, 30);
insert into Shopping_list values( 34232325, 52562523, 3);
insert into Shopping_list values( 82412845, 42515323, 7);
insert into Shopping_list values( 36272236, 69723642, 5);

CREATE TABLE Payment (
    Payment_id INT(150) NOT NULL,
    customer_ID INT(150) NOT NULL,
    Date_pay DATETIME NOT NULL,
    Shopping_list_id INT(50) NOT NULL,
    PRIMARY KEY (Payment_id),
    FOREIGN KEY (customer_ID)
        REFERENCES Customer_sign_in (customer_ID),
    FOREIGN KEY (Shopping_list_id)
        REFERENCES Shopping_list (Shopping_list_id)
);
insert into Payment values( 84163801, 19867889, '2013-05-25 07:12:00', 14081869);
insert into Payment values( 89171750, 11958178, '2013-04-08 21:43:12', 15163266);
insert into Payment values( 19829247, 52562523, '2013-04-02 16:41:09', 34232325);
insert into Payment values( 35819204, 42515323, '2013-03-25 23:54:32', 82412845);
insert into Payment values( 25085739, 69723642, '2013-03-20 12:38:56', 36272236);

CREATE TABLE Has (
    Product_id INT(150) NOT NULL,
    Recipes_id INT(150) NOT NULL,
    FOREIGN KEY (Product_id)
        REFERENCES Products (Product_id),
    FOREIGN KEY (Recipes_id)
        REFERENCES Recipes (Recipes_id)
);
insert into Has values( 509687, 513678);
insert into Has values( 485901, 513678);
insert into Has values( 908571, 513678);
insert into Has values( 357342, 867523);
insert into Has values( 123563, 867523);

CREATE TABLE Goes (
    Product_id INT(150) NOT NULL,
    Shopping_list_id INT(150) NOT NULL,
    FOREIGN KEY (Product_id)
        REFERENCES Products (Product_id),
    FOREIGN KEY (Shopping_list_id)
        REFERENCES Shopping_list (Shopping_list_id)
);
insert into Goes values( 485901, 14081869);
insert into Goes values( 123563, 14081869);
insert into Goes values( 908571, 14081869);
insert into Goes values( 485901, 82412845);
insert into Goes values( 123563, 34232325);
insert into Goes values( 357342, 34232325);

select * from Shopping_list;
select * from Payment;
select * from Customer_sign_in;
select * from Recipes;
select * from Products;
select * from Has;
select * from Goes;

SELECT c.customer_ID, p.Product_id, p.Product_price, s.Items_quantity,
(p.Product_price * s.Items_quantity) AS total FROM Products p LEFT JOIN Shopping_list s ON p.Product_id = s.Product_id LEFT JOIN Customer_sign_in c ON c.customer_ID = s.customer_ID;
创建数据库shopmeout; 使用shopmeout; 如果存在客户登录,则删除表; 创建表Customer\u sign\u in( 客户ID INT(50)不为空, 名称\u客户varchar(255)不为空, 信用卡BIGINT(100)不为空, 密码用户文本(150)不为空, 电子邮件客户文本(50)不为空, 主键(客户ID) ); 插入客户签名值(19867889,‘Stefan Darescu’,9018783269173917,‘personalcomputer84’,'stefandarescu@gmail.com'); 在客户签名中插入值(11958178,‘Mogens Hemming’、5090180120973782、‘masadebiliard4’、'mogenshemming@yahoo.com'); 在客户签名中插入值(52562523,‘Viggo Kristian’,9015908218093698,‘asawece’,'viggokristian@gmail.com'); 在客户签名中插入值(42515323,'Asbjørn Hjalmar',0198490128761903,'esrjgads','asbjornhjalmar@hotmail.com'); 插入客户签名值(69723642,'Rasmus Bjarne',9180583647839793,'Sgsyhdfs','rasmusbjarne@outlook.com'); 创建表格产品( 产品标识INT(150)不为空, 产品名称VARCHAR(100)不为空, 产品价格小数(6,2)不为空, 扣除价格整数(50)不为空, 截止日期不为空, 主键(产品标识) ); 插入产品价值(509687,“素花”,59.46,10,“2013-05-30”); 插入产品价值(485901,“牛奶”,17.85,12,“2013-04-18”); 插入产品价值(908571,'Kærgården',131.75,8,'2013-04-07'); 插入产品价值(432612,“鸡蛋”,27.57,9,“2013-03-31”); 插入产品价值(853235,“百事樱桃”,25.11,12,“2013-03-25”); 插入产品价值(357342,“意大利面”,10.8,5,“2013-03-20”); 插入产品价值(123563,“意大利面sos”、22.4、10、“2013-03-17”); 分隔符// 在产品更新之前,先创建触发器\u触发器 每行 开始 如果新产品价格<20,则 设置新产品价格=15; 否则,如果新产品价格>140 设置新产品价格=80; 如果结束; 结束// 定界符; 更新产品集Product_price=25,其中Product_id=509687; 更新产品集Product_price=22,其中Product_id=908571; 创建表格食谱( 配方id INT(10)不为空, 配方名称字符(150)不为空, 配方描述文本(255)不为空, 主键(配方\u id) ); 插入食谱值(513678,‘煎饼’,‘将鸡蛋打入搅拌器,加入面粉、牛奶和一小撮海盐,然后搅拌至光滑’; 插入食谱值(867523,'意大利肉酱面','在一个大锅中加热油,用中火将培根煎至金黄色'); 创建表格购物列表( 购物清单id INT(50)不为空, 客户ID INT(50)不为空, 项目数量INT(50)不为空, 主键(购物列表id), 外键(客户ID) 参考资料 客户登录(客户ID) ); 插入购物清单值(1408186919867889,15); 插入购物清单值(151632661195817830); 在购物清单中插入值(3423232552562523,3); 插入购物清单值(8241284542515323,7); 插入购物清单值(3627223669723642,5); 创建付款表( 付款id INT(150)不为空, 客户ID INT(150)不为空, 日期\付款日期时间不为空, 购物清单id INT(50)不为空, 主键(付款id), 外键(客户ID) 参考客户登录(客户ID), 外键(购物清单id) 参考购物清单(购物清单id) ); 插入付款金额(841638019867889,'2013-05-25 07:12:00',14081869); 插入付款金额(8917175011958178,'2013-04-08 21:43:12',15163266); 插入付款金额(19829247,52562523,'2013-04-02 16:41:09',34232325); 插入付款价值(3581920442515323,'2013-03-2523:54:32',82412845); 插入付款金额(2508573969723642,'2013-03-20 12:38:56',36272236); 创建表已完成( 产品标识INT(150)不为空, 配方id INT(150)不为空, 外键(产品标识) 参考产品(产品编号), 外键(配方\u id) 参考配方(配方\u id) ); 插入Has值(509687513678); 插入Has值(485901、513678); 插入Has值(908571513678); 插入Has值(357342867523); 插入Has值(123563867523); 创建表格( 产品标识INT(150)不为空, 购物清单id INT(150)不为空, 外键(产品标识) 参考产品(产品编号), 外键(购物清单id) 参考购物清单(购物清单id) ); 插入Goes值(485901、14081869); 插入Goes值(12356314081869); 插入Goes值(90857114081869); 插入Goes值(485901、82412845); 插入Goes值(123563、342325); 插入Goes值(357342、342325); 从购物列表中选择*; 从付款中选择*; 从客户登录中选择*; 从配方中选择*; 从产品中选择*; 从Has中选择*; 从Goes中选择*; 选择c.客户ID、p.产品ID、p.产品价格、s.项目数量、, (p.Product_price*s.Items_quantity)作为p.Product_id=s.Product_id LEFT JOIN Customer_sign_c.Customer_id=s.Customer_id上的产品p LEFT JOIN Shopping_list s的总计;
是的,我有两个表。请稍候,它显示另一个错误:错误代码:1054。未知柱