SQL- Tips in deploying pgAdmin3 & sql commands

SQL tips

pgAdmin3

1. How to open a data file in pgAdmin3:

1) 创建数据库,名为Parch
2)打开,输入 服务器localhost:5432 , 数据库Parch, 用户名postgres
3)运行=》因此parch里就有数据了

2. How to write code?

1) 第二行第六个图标 输入代码=》出结果

3. How to write comments?

Shortcut : CTRL + K , cancel- CTRL + K +SHIFT

4. Some common mistakes - diffenrence between R and other languages.

sql大小写无所谓(R有所谓)
必须加;(R不加)
where 在后面
String用’’单引号(R“”双引号)但是命名用“”
模糊搜索%

JOIN

select o.id, a.name, o.total from orders o
join accounts a
on o.account_id = a.id where(and) a.name = ‘Walmart’

select from join on join on where(and)
o.id, a.name, o.total, distinct orders o accounts a o.account_id = a.id inner相交/Left照顾到表一/Right照顾到表二/Outter join 全部 a.name = ‘Walmart’

(where can be replaced by and)
(using(id) can only be used when the names of keys are same, Otherwies, on ..=… plz)