- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 PHP 脚本在同一个 MySQL 数据库中创建 2 个表:表“user”的主键为“user_id”,表“order”的主键为“order_id”,外键“user_id”来自“user”表(一对多关系)。
表用户创建成功,没有问题:
$sql="CREATE TABLE user(
user_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
type ENUM('member','admin') NOT NULL,
username VARCHAR(30) NOT NULL,
email VARCHAR(80) NOT NULL,
pass VARBINARY(32) NOT NULL,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(40) NOT NULL,
date_expires DATE NOT NULL,
date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
date_modified TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (user_id),
UNIQUE (username),
UNIQUE (email)
)ENGINE=InnoDB DEFAULT CHARSET=utf8";
但是,我无法创建表顺序:
$sql="CREATE TABLE order(
order_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
user_id INT UNSIGNED NOT NULL,
transaction_id VARCHAR(19) NOT NULL,
payment_status VARCHAR(15) NOT NULL,
payment_amount DECIMAL(6,2) UNSIGNED NOT NULL,
payment_date_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (order_id),
FOREIGN KEY (user_id) REFERENCES user (user_id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8";
我收到以下错误:
Error creating table: 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 'order( order_id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id ' at line 1
已经检查了语法,找不到错误。您能告诉我出了什么问题吗?非常感谢。
最佳答案
关于mysql - 创建表时出错 : You have an error in your SQL syntax near 'order( order_id INT UNSIGNED NOT NULL AUTO_INCREMENT, user_id ' at line 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24981928/
我有一些地址字符串需要针对每个组件进行分析。 SQL Fiddle Demo CREATE TABLE Table1 ("ID" int, "address" varchar(41)); INSERT
访问 SearchResults 对象中 ScoredDocument 对象的 order_id 属性会在日志中生成以下错误: 弃用警告:order_id 已弃用;改为使用排名 logging.deb
我在同一数据库中有两个表,一个名为“产品”,另一个名为“客户”,我需要获取 customer.order_id、customer.name、customer.order_total、products.
我正在研究 React Native Razorpay 支付网关集成。 我正在使用 react-native-razorpay。 代码如下:- 发送参数是:- var options = {
我有一个 api 函数,如果订单来自多个餐厅,我会使用多个订单 ID。这是我得到的回应。 ["00000303", "00000304"] 这是我的代码,它在 Json 中返回值 $new_o
目前我有这个查询: SELECT refnumbers.order_id FROM orders INNER JOIN refnumbers ON (refnumbers.order_id = ord
我想在 mysql db 中插入 order_ids 数组作为一个接一个地插入,就像我将 order_ids 变量作为 $order_ids = (123,223,354,343,566,334);
使用 WooCommerce,在提交新订单后,我的 function.php 中有以下 Hook : add_action( 'woocommerce_new_order', 'create_job_
This is the A/B Experiment table with 4 columns: 1. user_id 2. experiment_id 3. experime
我意识到很多代码都是挥手和炫耀的,我不会因此而获得荣誉。该代码成功执行了所有查询,除了当我尝试显示带有 order_id 的收据页面时,我为 order_id 创建的 vairable 未返回。 选项
我有两个表 X 和表 Y。X 有 order_id,offer_id。一个 order_id 可以有多个 offer_id。现在我想将数据插入到 Y(id,offer_id) 中,对于每个不同的 of
我有一个复杂的 SQL 代码需要编辑,以便它根据 order_ID 对订单信息进行分组。现在,单个产品有数量,product_totals 列出(即订单有多个产品,多个 order_ID)。 这是我的
我在我的网站上使用旧的 mysql 版本和 php 版本 4。 我的表结构: | orders_status_history_id | orders_id | orders_status_id |
我下面的查询返回以下错误消息“‘on 子句’中的未知列‘O.order_id’”。我猜这是一个优先级问题?但我没有足够的背景来弄清楚它可能在哪里。 我最近刚刚添加了“where”子句,以便我可以过滤产
这个问题在这里已经有了答案: Custom SERIAL / autoincrement per group of values (3 个答案) MySQL: Add sequence column
假设您有一个 HTML 表单: 使用@RequestParam,您可以将字段绑定(bind)为单独的参数: public String doAjax(@RequestParam("in
这个问题已经有答案了: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答) 已关闭
这个问题在这里已经有了答案: Syntax error due to using a reserved word as a table or column name in MySQL (1 个回答)
我是一名优秀的程序员,十分优秀!