france

https://github.com/francecil

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
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)

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

posted on 2014-11-14 22:42  france  阅读(183)  评论(0编辑  收藏  举报