第二个表列内连接

时间:2018-05-08 09:09:20

标签: sql oracle

我无法选择列,因为我收到SQL命令未正确结束错误

(
  select mobile_no,SIM_NO,START_DATE,END_DATE 
  from (
    select mobile_no,SIM_NO,START_DATE,END_DATE
    from employee_1 
  ) myemployee
) join ( 
   ( select mobile_1.mobile_no,mobile_1.status  
     from mobile_1 
) as mymobile ) on myemployee.mobile_no = mymobile.mobile_no

提前致谢。如果这是工作,我将在我的项目中应用它。

1 个答案:

答案 0 :(得分:0)

这个可能会更好:

SELECT mobile_no,
       sim_no,
       start_date,
       end_date
  FROM (SELECT mobile_no,
               sim_no,
               start_date,
               end_date
          FROM employee_1) myemployee
       JOIN
       (SELECT mobile_1.mobile_no, mobile_1.status FROM mobile_1) mymobile
          ON myemployee.mobile_no = mymobile.mobile_no;

[编辑,基于a_horse的评论]

SELECT e.mobile_no,
       e.sim_no,
       e.start_date,
       e.end_date
  FROM employee_1 e JOIN mobile_1 m ON m.mobile_no = e.mobile_no