MySql常用操作SQL語句彙總

farsun發表於2021-09-09

MySQL的常見操作在這裡先做一下總結,已經整合到程式碼裡面,經過檢驗無誤。

複製程式碼 程式碼如下:

create database xuning_test;

use xuning_test;

create table person(
 id int not null,
 name varchar(16) not null,
 sex varchar(16) not null,
 age int not null,
 address varchar(128) not null,
 remark varchar(512) not null
);

insert into person value
 (1,'name_1','men',99,'beijing','This is a frindsheep boy'),
 (2,'name_2','men',88,'shanghai','ok great'),
 (1,'name_3','man',77,'guangzhou','This is lickly'),
 (1,'name_4','men',66,'beijing','This is a frindsheep boy'),
 (1,'name_5','men',55,'beijing','you dont going to shool'),
 (1,'name_6','man',44,'beijing','This is a frindsheep boy'),
 (1,'name_7','men',33,'beijing','This is a frindsheep boy'),
 (1,'name_8','man',22,'beijing',''),
 (1,'name_9','men',11,'beijing','This is a frindsheep boy')
;

select * from person;


select name from person;

select name from person where sex = 'men';

select name,address from person where age > 50;

select xuning_test.person.name, xuning_test.person.id, xuning_test.person.age, xuning_test.person.address
from xuning_test.person, test1.test_xuning
where xuning_test.person.id = test1.test_xuning.id
;

use xuning_test;
select c.name,sex from person as c where c.age > 40 and c.address='beijing';


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/4289/viewspace-2804579/,如需轉載,請註明出處,否則將追究法律責任。

相關文章