zoukankan      html  css  js  c++  java
  • dazhewang数据库初设计

    mysql> use dazhe;
    Database changed
    mysql> create table shops(id int primary key auto_increment not null,name varchar(100),info varchar(200
    Query OK, 0 rows affected (0.41 sec)
    
    mysql> create table lanmu(id int primary key auto_incrememt not null,name varchar(100),fatherid int);
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MyS
    herid int)' at line 1
    mysql> create table lanmu(id int primary key auto_incrememt not null,name varchar(100),fatherid int);
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MyS
    herid int)' at line 1
    mysql> create table lanmu(id int ,name varchar(100),fatherid int);
    Query OK, 0 rows affected (0.14 sec)
    
    mysql> create table sl(sid int,lid int);
    Query OK, 0 rows affected (0.14 sec)
    
    mysql> insert into shops(id,name,info) values(,'nike','45%');
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MyS
    mysql> insert into shops(id,name,info) values(,'nike','0.6');
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MyS
    mysql> insert into shops(id,name,info) values(1,'nike','0.6');
    Query OK, 1 row affected (0.08 sec)
    
    mysql> insert into shops(id,name,info) values(2,'adidas','0.4');
    Query OK, 1 row affected (0.08 sec)
    
    mysql> insert into shops(id,name,info) values(3,'puma','0.8');
    Query OK, 1 row affected (0.06 sec)
    
    mysql> insert into lanmu(1,'boy',0);
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MyS
    mysql> insert into lanmu(id,name,fatherid) values(1,'boy',0);
    Query OK, 1 row affected (0.08 sec)
    
    mysql> insert into lanmu(id,name,fatherid) values(2,'girl',0);
    Query OK, 1 row affected (0.07 sec)
    
    mysql> insert into lanmu(id,name,fatherid) values(3,'famous',0);
    Query OK, 1 row affected (0.39 sec)
    
    mysql> insert into lanmu(id,name,fatherid) values(4,'boyshoe',1);
    Query OK, 1 row affected (0.12 sec)
    
    mysql> insert into lanmu(id,name,fatherid) values(5,'pants',1);
    Query OK, 1 row affected (0.11 sec)
    
    mysql> insert into lanmu(id,name,fatherid) values(6,'girlpants',2);
    Query OK, 1 row affected (0.08 sec)
    
    mysql> insert into lanmu(id,name,fatherid) values(7,'witch',3);
    Query OK, 1 row affected (0.07 sec)
    
    mysql> create table lanmu_shopname(id,lid int,sname varchar(100));
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MyS
    mysql> create table lanmu_shopname(id int,lid int,sname varchar(100));
    Query OK, 0 rows affected (0.26 sec)
    
    mysql> insert into lanmu_shopname(id,lid,sname) values(1,1,'nike');
    Query OK, 1 row affected (0.08 sec)
    
    mysql> insert into lanmu_shopname(id,lid,sname) values(2,1,'adidas');
    Query OK, 1 row affected (0.08 sec)
    
    mysql> select * from lanmu where id=1;
    +------+------+----------+
    | id   | name | fatherid |
    +------+------+----------+
    |    1 | boy  |        0 |
    +------+------+----------+
    1 row in set (0.00 sec)
    
    mysql> select * from lanmu_shopname where id=1;
    +------+------+-------+
    | id   | lid  | sname |
    +------+------+-------+
    |    1 |    1 | nike  |
    +------+------+-------+
    1 row in set (0.00 sec)
    
    mysql> select * from lanmu_shopname where lid=1;
    +------+------+--------+
    | id   | lid  | sname  |
    +------+------+--------+
    |    1 |    1 | nike   |
    |    2 |    1 | adidas |
    +------+------+--------+
    2 rows in set (0.00 sec)
    
    mysql> select sname from lanmu_shopname where lid=1;
    +--------+
    | sname  |
    +--------+
    | nike   |
    | adidas |
    +--------+
    2 rows in set (0.00 sec)
    
    mysql> select * from shop where sname in(select sname from lanmu_shopname where lid =1);
    ERROR 1146 (42S02): Table 'dazhe.shop' doesn't exist
    mysql> select * from shops where sname in(select sname from lanmu_shopname where lid =1);
    ERROR 1054 (42S22): Unknown column 'sname' in 'IN/ALL/ANY subquery'
    mysql> select * from shops where name in(select sname from lanmu_shopname where lid =1);
    +----+--------+------+
    | id | name   | info |
    +----+--------+------+
    |  1 | nike   | 0.6  |
    |  2 | adidas | 0.4  |
    +----+--------+------+
    2 rows in set (0.02 sec)
    

    版权声明:本文为博主原创文章,未经博主允许不得转载。

    today lazy . tomorrow die .
  • 相关阅读:
    String系列
    java初始化构造函数调用顺序
    转发和重定向的区别
    HttpServletResponse对象
    JSP九大隐式对象
    关于异常
    MySQL下载、安装及启动
    MySQL的启动
    MySQL下载及安装
    U盘安装Win7操作系统
  • 原文地址:https://www.cnblogs.com/france/p/4808605.html
Copyright © 2011-2022 走看看