0

如何在一个查询中从没有关系的表中选择这个 SELECTs?

SELECT discount_rate.valueSet, discount_rate.dateSet 
FROM discount_rate 
WHERE discount_rate.dateSet<='2011-12-11' 
ORDER BY discount_rate.dateSet DESC LIMIT 1; 

SELECT min_wage.valueMonth AS min_wage_month, min_wage.valueDay AS min_wage_day 
FROM min_wage 
WHERE min_wage.dateSet<='2011-12-11' 
ORDER BY min_wage.dateSet DESC LIMIT 1;

SELECT max_wage.valueWage 
FROM max_wage 
WHERE max_wage.dateSet<='2011-12-11' 
ORDER BY max_wage.dateSet DESC LIMIT 1;
4

1 回答 1

2

由于 3 个查询中的每一个都返回一行,因此您可以将它们包装在一个查询中CROSS JOIN

SELECT valueSet
     , dateSet
     , valueMonth
     , valueWage 
FROM
    ( SELECT ... ) AS q1        --- subquery 1
  CROSS JOIN
    ( SELECT ... ) AS q2        --- subquery 2
  CROSS JOIN
    ( SELECT ... ) AS q3        --- subquery 3
于 2011-12-12T11:37:57.463 回答