2. Writing Simple SQL Statements
每条SQL完结时才有「;」runSQL:mouse pointer + Ctrl + Enter
SQL statements are not case sensitive.
keywords不能缩短或者分隔两行。
Tab和首行缩排是用作提高阅读能力。
SELECT identidies the columns to be displayed.
FROM identidies the table that contains the columns.
基本格式:
select xxx, yyy
from zzz;
(表示选取zzz中,xxx, yyy部分,如在zzz中全部都选取的则以*表示,不用列出)
Operations:
+(add), -(subtract), *(multiply), /(divide)
计算时,不用from,直接写即可。
例子: 计算xxx+100,写selete xxx+100; 从zzz中选取yyy及计算yyy*100,写select yyy, yyy*100 from zzz
帮column改名(Alias)可以使用as或者空格表示「更改为」
例如:从zzz中取出xxx并更改名为yyy
select xxx yyy//若yyy是case sensitive或者包含空格,刚需使用双引号。
from zzz;
只可在没更改table结构下更改column名字
Duplicate Rows(完全一样的行): The default display of queries is all rows, including duplicate rows.
Eliminating Duplicate Rows: 在select clause用distinct把重复的排除。
例如:从zzz中取出xxx并把重复的排除
select dictinct xxx
from zzz;
What is MySQL Workbench?
A command line SQL and reporting tool for working with MySQL Severs and database.
页:
[1]