MySQL如何建立查询数据


1. 数据库
create database 1name;      建成后use 1name;

2. 建数据表
create table `2name`( `name1`     数据类型(字符长度)  not null ,`name2`     数据类型(字符长度)  nut null ,  .........);
注:not null 可不输入。
3. 插入数据

insert into  2name  (name1,name2,.....)  values  ('内容1','内容2',........);


或  insert into  2name  values  ('内容1','内容2',........);  --> 必须将定义的数据全打一遍。

注:输入内容也可用“ ”,但最好用  ' '   ;一次只能输入一条数据。

4. 查数据
show databases;-->use 所查数据库名;-->show tables;-->select * from 所查数据表名;
select 表1 . *,表2 . x from 表1,表2 where 表1.did=表2.id; --> 显示表1中的did = 表2中的id时的全部表1信息及表2的x信息。

注:*表示全部,x,id表示 表2中的一个数据,did表示 表1中的一个数据。

注:alter table 数据表名 CONVERT TO CHARACTER SET utf8;    识别汉语。

猜你喜欢

转载自blog.csdn.net/sauvegarder/article/details/80215608