我是靠谱客的博主 忧虑太阳,最近开发中收集的这篇文章主要介绍《快速念咒——MySQL自学入门指南》:第2章——从表中获取更多数据(前言),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
欢迎大家扫码关注订阅号:在这里插入图片描述

下一节我们将会使用两张新表——happyorderhappydetail。创建两张表的代码如下——

创建happyorder表:

CREATE TABLE happyorder
(
  menu_num  int      NOT NULL AUTO_INCREMENT,
  order_time datetime NOT NULL ,
  tab_num    int      NOT NULL ,
  per_num int NOT NULL,
  new_client char(10) NULL,
  PRIMARY KEY (menu_num)
) ENGINE=InnoDB;

创建happydetail表:

CREATE TABLE happydetail
(
  menu_num  int          NOT NULL ,
  menu_item int          NOT NULL ,
  dishes    char(10)     NOT NULL ,
  quantity   int          NOT NULL ,
  price decimal(8,2) NOT NULL ,
  PRIMARY KEY (menu_num, menu_item)
) ENGINE=InnoDB;

happyorder表中插入数据:

INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1001, '2005-09-01 17:30:01','1', '4', null);
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1002, '2005-09-01 18:31:41','2', '2', 'Yes');
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1003, '2005-09-01 18:35:51','3', '3', null);
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1004, '2005-09-01 18:40:51','5', '8', 'Yes');
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1005, '2005-09-01 18:48:51','7', '1', null);
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1006, '2005-09-01 19:35:51','1', '2', 'Yes');
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1007, '2005-09-01 19:40:51','2', '3', null);
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1008, '2005-09-01 20:10:51','4', '3', 'Yes');
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1009, '2005-09-01 20:50:51','1', '1', null);
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1010, '2005-09-01 20:30:51','2', '6', 'Yes');
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1011, '2005-09-01 20:30:51','3', '4', 'Yes');
INSERT INTO happyorder(menu_num, order_time, tab_num, per_num, new_client)
VALUES(1012, '2005-09-01 21:00:51','6', '5', 'Yes');

happydetail表中插入数据:

INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1001', '1', '冰火菠萝油','2','11.5');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1001', '2', '海鲜大什扒','4','50');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1002', '1', '烤鲱鱼','5','20');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1002', '2', '烧味八宝饭','2','42');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1002', '3', '风暴雷霆烈酒','2','19');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1003', '1', '干酪水饺','3','21');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1003', '2', '烤鲱鱼','3','20');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1004', '1', '咖喱牛肉','4','26');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1004', '2', '鳗鱼拌饭','4','24');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1004', '3', '冻奶茶','8','15');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1005', '1', '菠萝焗猪扒饭','1','40');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1005', '2', '红豆冰','1','12');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1006', '1', '烤鲱鱼','2','20');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1006', '2', '自选双拼','2','22');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1007', '1', '烤鲱鱼','3','20');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1007', '2', '海胆饭','3','50');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1008', '1', '咖喱海鲜饭','2','58');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1008', '2', '美式什扒饭','1','39');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1008', '3', '冻啤酒','3','8');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1009', '1', '烤鲱鱼','2','20');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1009', '2', '奶油仔包','2','9.5');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1010', '1', '海鲜火锅','2','80');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1010', '2', '烧鹅','2','40');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1010', '3', '芒果布丁','6','16');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1010', '4', '海鲜焗饭','2','45');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1011', '1', '罗宋汤','2','16');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1011', '2', '芝士焗生蚝','8','5');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1011', '3', '西班牙海鲜意粉','4','45');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1012', '1', '肉酱窝蛋饭','3','44');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1012', '2', '海鲜焗饭','2','40');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1012', '3', '焦糖布丁','5','18');
INSERT INTO happydetail(menu_num, menu_item, dishes,quantity, price)
VALUES('1012', '4', '冻啤酒','5','8');

最后

以上就是忧虑太阳为你收集整理的《快速念咒——MySQL自学入门指南》:第2章——从表中获取更多数据(前言)的全部内容,希望文章能够帮你解决《快速念咒——MySQL自学入门指南》:第2章——从表中获取更多数据(前言)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(32)

评论列表共有 0 条评论

立即
投稿
返回
顶部