MYSQL Common Operations SQL statement Rollup _mysql

Source: Internet
Author: User
Tags create database

The common operation of MySQL here first to do a summary, has been integrated into the code, after the inspection is correct.

Copy Code code as follows:

/* Create a database/*
Create Database xuning_test;
/* Description of using Database object at that time/*
Use Xuning_test;
/* Add tables to the database and define the structure of the table * *
CREATE TABLE Person (
ID int NOT NULL,
Name varchar NOT NULL,
Sex varchar () NOT NULL,
Age int is not NULL,
Address varchar (128) is not NULL,
Remark varchar () NOT NULL
);
/* Insert data into the table in the database/*
INSERT INTO person value
(1, ' name_1 ', ' Men ',}, ' Beijing ', ' This is a frindsheep boy '),
(2, ' name_2 ', ' Men ', ' Shanghai ', ' OK Great '),
(1, ' name_3 ', ' man ', +, ' Guangzhou ', ' This is lickly '),
(1, ' name_4 ', ' Men ', $, ' Beijing ', ' This is a frindsheep boy '),
(1, ' name_5 ', ' Men ', ' Beijing ', ' you dont going to shool '),
(1, ' name_6 ', ' Man ', ' Beijing ', ' the ' is a Frindsheep boy '),
(1, ' name_7 ', ' Men ', ' Beijing ', ' This is a frindsheep boy '),
(1, ' name_8 ', ' Man ', ' Beijing ', '),
(1, ' name_9 ', ' Men ', one, ' Beijing ', ' This is a frindsheep boy ')
;
/* Query was successfully inserted * *
select * from person;
/* Below is a variety of query methods * *
/* Based on the name attribute value of the column * *
select name from person;
/* Add condition-according to sex * *
Select name from person where sex = ' men ';
/* You can also use the comparator as a condition--a certain comma-separated/
Select name,address from person where age > 50;
/* As object to use database and table relationship =---two-table association--object relationship must be clear/
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 the alias of the table to inquire * *
Use Xuning_test;
Select C.name,sex from person as C where c.age > and c.address= ' Beijing ';

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.