2020年12月17日 星期四

Python List Comprehension

  List Comprehension沒有統一譯名(數學推論出的式子)

#列表推導式

# 列表高效率單行建構
arr1 = [i for i in range(10)]

# 列表內元素限制產生
arr2 = [x for x in arr1 if x % 2 == 0]

# 列表內元素多重限制產生
arr3 = [x for x in arr1 if x >= 3 and x % 2]

# 巢狀列表元素產生
arr4 = [(x, y) for x in range(3) for y in range(4)]

print(arr1)
print(arr2)
print(arr3)
print(arr4)

2020年12月9日 星期三

SQL 一次insert 多筆

 -- 傳統

 insert into test.customer(pin,first_name,last_name) values(601,"Bush","Kim");

 insert into test.customer(pin,first_name,last_name) values(602,"Grace","Kun");

 insert into test.customer(pin,first_name,last_name) values(603,"Jully","LAin");


-- oracle 

insert all 

into test.customer(pin,first_name,last_name) values(601,"Bush","Kim")

into test.customer(pin,first_name,last_name) values(602,"Grace","Kun")

into test.customer(pin,first_name,last_name) values(603,"Jully","LAin");


-- mysql

insert into customer(pin,first_name,last_name) 

values(601,"Bush","Kim"),

(602,"Grace","Kun"),

(603,"Jully","LAin");