在表A中有如下列: program_id,program_start_time,qc_state,chanel_id, 请使用sql语句找出chanel_id为10,qc_state为5的program_id,并使其按照program_start_time进行排序; 在表B中有如下列: Ticket_id,program_id,device_id, 请使用sql语句找出表B中program_id与上一题查询结果相符合的ticket_id和device_id
select * from A where chanel_id = 10 and qc_state = 5 order by program_start_time;
select ticket_id,device_id from B where program_id in
(
select program_id from A where chanel_id = 10 and qc_state = 5 order by program_start_time
);
select program_id from A where chanel_id=10 and qc_state=5 order by program_start_time;
select ticket_id,device_id from B where program_id in (select program_id from A where chanel_id=10 and qc_state=5);
select
program_id
from A
where chanel_id=10
and qc_state=5
order by program_start_time
;
select
ticket_id
,device_id
from B t1
JOIN
(
select
program_id
from A
where chanel_id=10
and qc_state=5
) t2
ON t1.program_id=t2.program_id
;
编程大法好是正解
select a.*, b.ticked_id,b.device_id from A as a,B as b where a.program_id = b.program_id and a.chanel_id=10 and a.qc_state=5 order by a.program_start_time