Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- select URL entities, not yet downloaded
- -- entity id + lowest pubDate, pubTime of its' instances
- SELECT
- e.id,
- e.name,
- d.pubDate,
- d.pubTime
- FROM entities e, instances i, documents d
- WHERE
- e.id=(
- SELECT ee.id
- FROM entities ee
- WHERE ee.enttype_id=9
- AND NOT EXISTS (SELECT * FROM downloadurl WHERE entity_id=ee.id)
- LIMIT 1
- )
- AND i.entity_id=e.id -- JOIN
- AND i.item_id=d.id -- JOIN
- ORDER BY (d.pubDate + d.pubTime)
- LIMIT 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement