SQL statement One

Source: Internet
Author: User

using data

Use MyData;

Create a table
CREATE TABLE Longmao
(
Depeno int PRIMARY KEY,
Dname varchar (20),
Loc varchar (20)

);

inserting data into the table

Inseert into Toroto values (1, ' Feifei ');

Show all the tables

Show tables;

Show data in table

SELECT * from Toroto;

Left join

SELECT * from T1 LEFT join t2 on t1.id = t2.id;

Right join

SELECT * from T1 right join t2 on t1.id = t2.id;

Show all the database

show databases;

Show Table structure

Desc Toroto;

Select a row from line 3rd

SELECT * from Toroto ORDER BY id DESC limit 3, 1;

Delete Data from a table

Delete from Toroto;

Delete a table

drop table Toroto;

auto_increment
CREATE TABLE Toroto
(
ID int primary KEY auto_increment,
Name varchar (20)
);
null

INSERT into Toroto values (null, ' pangpang1 ');

Insert only the name of this element

Insert into Toroto (name) VALUES (' Pangpang3 ');

Show Current time

Select Now ();

add a column to the home after name

ALTER TABLE Toroto Add home varchar (+) after name;

Delete Home This field

ALTER TABLE Toroto drop home;

replace name with ID 1 to Baobao

Update Toroto Set name = ' Baobao ' WHERE id = ' 1 ';

Select two tables with the same ID data

SELECT * from Toroto,toroto2 where toroto.id = toroto2.id;

Select the id=2 data in the table
SELECT * from Toroto where id = 2;

SQL statement One

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.