mysql語句筆記

來源:互聯網
上載者:User

標籤:限制   語句   create   .exe   play   網站   comment   distinct   注入   

CREATE TABLE `player` (  `id` int(11) NOT NULL AUTO_INCREMENT,  `name` char(20) NOT NULL DEFAULT ‘‘ COMMENT 網站名稱,  `area` varchar(255) NOT NULL DEFAULT ‘‘,  `alexa` int(11) NOT NULL DEFAULT 0 COMMENT Alexa 排名,  `team` char(10) NOT NULL DEFAULT ‘‘ COMMENT 國家,  PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;INSERT INTO `player` VALUES (1, Leonard, 美國聖安東尼奧, 95, 馬刺), (2, Curry, 美國金州, 94, 勇士), (3, Durant, 美國金州, 93, 勇士), (4, James, 美國克利夫蘭, 92, 騎士), (5, Lillard, 美國奧克蘭, 89, 開拓者);

上面先是建立表頭,然後插入資料

表與庫概念,(庫database相當於檔案袋,裡面有很多table表)
show databases;//查看庫
use Map;//使用某個庫
show table;//在庫中顯示所有的表
select * from player;//搜尋表msg中的表資料

 

 

以上學習在資料庫learndb中學習,裡面注入了sql指令碼
基本概念
1.資料庫是一個管理資料的軟體
2.mysql的用戶端有很多(mysql.exe,phpmyadmin,navicat)
mysql.exe是純命令列的用戶端
基礎操作:
最基礎的:
show databases;查看庫
use test;選庫
show tables;查看庫的表
select * from player;檢索所有的列

稍微要記得:
檢索資料:
1.檢索所有的列 select * from products;
2.檢索不同的值 select distinct vend_id from products;
3.檢索限制結果 select prod_name from products limit 5;

排序檢索資料:
1.排序資料 select prod_name from products order by prod_name;
2.多個列排序select prod_id,prod_price,prod_name from products order by prod_price,prod_name;
3.列位置排序select prod_id,prod_price,prod_name from products order by 2,3;
4.降序排列select prod_id,prod_price,prod_name from products order by prod_price DESC;


過濾資料:
1.使用WHERE子句
select prod_name,prod_price from products where prod_price=3.49;
以下為WHERE子句的操作符:
(1)檢查單個值:where prod_price<=10;
(2)不匹配檢查:SELECT vend_id, prod_name FROM Products WHERE vend_id <> ‘DLL01‘;
(3)範圍值檢查:SELECT prod_name, prod_price FROM Products WHERE prod_price BETWEEN 5 AND 10;
(4)空值檢查:
進階過濾:

mysql語句筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.