日期:2014-05-16  浏览次数:20825 次

急!在线等!mysql右表引用左表字段值的问题?
SQLServer中有这样的语句:
SELECT
a.col1, b.col1, b.col2
FROM ta a
  CROSS APPLY (
SELECT
  tb.col1, tb.col2
FROM tb
  WHERE tb.col3 = a.col1
  )b
GROUP BY a.col1;
这样的语句,mysql怎么实现??

------解决方案--------------------
SELECT a.col1, b.col1, b.col2
FROM tb b inner join ta a on b.col3 = a.col1

CROSS APPLY:类似INNER JOIN

------解决方案--------------------
SELECT a.col1, b.col1, b.col2
FROM tb b inner join ta a on b.col3 = a.col1
------解决方案--------------------
引用不要 join,我最初用的是join,性能很差!!!