mysql - 表中不存在 MySQL 键列“product_id”
问题描述
我正在尝试按照这个视频上课,但我遇到了一个错误,但我看不到它在视频中的位置,而且我对使用命令提示符和 MySQL 来查看它太陌生了。
这是错误“第 49 行:表中不存在键列‘product_id’”
这是需要的视频https://www.youtube.com/watch?v=ec--JuXWVu4
这是代码
create database if not exists customers;
use customers;
drop table if exists phonenumbers;
drop table if exists product_orders;
drop table if exists products;
drop table if exists orders;
drop table if exists customers;
CREATE TABLE customers (
id int(11) NOT NULL auto_increment,
first_name varchar(20) NOT NULL,
last_name varchar(20) NOT NULL,
street varchar(25),
state char(2) NOT NULL,
zip char(5),
city varchar(20),
PRIMARY KEY(id)
);
CREATE TABLE phonenumbers (
id int(11) NOT NULL auto_increment,
customer_id int(11) NOT NULL,
phone_number varchar(10) NOT NULL,
PRIMARY KEY(id),
FOREIGN KEY(customer_id) references customers(id)
);
create table orders (
id int(11) NOT NULL auto_increment,
customer_id int(11) NOT NULL,
date_ordered datetime default current_timestamp,
date_delivered datetime,
total decimal(7, 2),
PRIMARY KEY(id),
FOREIGN KEY(customer_id) references customers(id)
);
create table products (
id int(11) NOT NULL auto_increment,
name varchar(50) NOT NULL,
description varchar(255),
price decimal(5, 2) NOT NULL,
qty int(10) NOT NULL,
PRIMARY KEY(id)
);
create table product_orders (
product_is int(11) NOT NULL,
order_id int(11) NOT NULL,
qty int(10) NOT NULL,
PRIMARY KEY(product_id, order_id),
FOREIGN KEY(product_id) references products(id),
FOREIGN KEY(order_id) references orders(id)
);
解决方案
product_是int(11) NOT NULL,正确的是 product_id,对吗?
推荐阅读
- r - RStudio ggplot 对数图
- asynchronous - 为什么将 Tokio 与 std::sync::Mutex 一起使用时会出现死锁?
- javascript - 使用node js中的动态变量值获取json文件的值
- ibm-mq - 我可以停止特定队列吗?
- html - 当屏幕宽度低于最大宽度时,如何将锚点移动到 div 的顶部?
- javascript - 我可以根据 React 中的搜索框输入过滤元素吗?
- datatable - 返回 f 的 ColdFusion 数据表未定义
- azure - 从 Azure Devops 仪表板小部件自定义查询
- python - 让一个线程在后台python中不断运行
- pandas - Fetch_pandas vs Unload as Parquet - 使用 Python 连接器卸载雪花数据