sql造数据


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

在操作中,有时要用几个数据造成一查询表处理数据,通常的做法是select union all,现提供另一种方法:

SELECT *
FROM (VALUES (1,2),(3,4),(5,6)) AS t(a,b)

相当于
SELECT *
FROM(
 SELECT 1 a, 2 b
  UNION ALL   
  SELECT 3 a,4 b
  UNION ALL   
  SELECT 5 a,6 b

)t