使用联结: SELECT cust_name,cust_contact FROM customers,orders,orderitems WHERE customers.cust_id = orders.cust_id AND orders.order_num = orderitems.order_num AND prod_id = 'RGAN01' example.png
数据库学习笔记——11使用子查询 1 子查询 即嵌套在其他查询中的查询。MySQL从4. 3.png 注意:作为子查询的SELECT语句只能查询单个列。 3 作为计算字段使用子查询 举例说明:列出Customers表中每个顾客的订单总数。 SELECT cust_name,cust_state,(SELECT COUNT(*) FROM orders WHERE orders.cust_id=customers.cust_id) AS orsers FROM customers ORDER BY cust_name 4.png 此例中,子查询执行了5次
此语句的输出如下图所示: 这条语句通过WHERE子句从视图中检索特定数据。在MySQL处理此查询时,它将指定的WHERE子句添加到视图查询中的已有WHERE子句中,以便正确过滤数据。 二、用视图重新格式化检索出的数据 CREATE VIEW vendorlocations AS SELECT Concat(RTrim(vend_name),'(',RTrim(vend_country),')') AS vend_title FROM vendors ORDER BY vend_name; SELECT * FROM customeremaillist;
([0-9]{1,2}|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\b', text) # print(result) 4.写尽可能多的str对象的方法 str1 = 'a,b,c,,D,11,222.33.55' print str1.split('.union(set(b2))) ^ set(b1) ^ set(b2)) # 求交集 print same diff = [] # 求差集 for i in b1: if i not in b2: diff.append(i) for i in b2: if i not in b1: diff.append(i) print diff union = list(set(b1).