summaryrefslogtreecommitdiff
path: root/p2pvr/lib/sql/SI_serviceNextUsed.sql
diff options
context:
space:
mode:
Diffstat (limited to 'p2pvr/lib/sql/SI_serviceNextUsed.sql')
-rw-r--r--p2pvr/lib/sql/SI_serviceNextUsed.sql12
1 files changed, 12 insertions, 0 deletions
diff --git a/p2pvr/lib/sql/SI_serviceNextUsed.sql b/p2pvr/lib/sql/SI_serviceNextUsed.sql
new file mode 100644
index 0000000..8e906ad
--- /dev/null
+++ b/p2pvr/lib/sql/SI_serviceNextUsed.sql
@@ -0,0 +1,12 @@
+SELECT dd.*
+FROM delivery_dvbt dd, services s
+ LEFT OUTER JOIN record r
+ ON r.serviceid = s.serviceid
+ AND r.recordstatus = 0
+ LEFT OUTER JOIN events e
+ ON r.eventid = e.eventid
+ AND r.serviceid = e.serviceid
+ AND e.starttime > NOW()
+WHERE dd.transportstreamid = s.transportstreamid
+ORDER BY e.starttime, s.serviceid
+LIMIT 1