Advanced Database Query Exercise: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>Hendrik Brummermann
Created page with "This is an advanced version of the basic Database Query Exercise. You should probably do that one first. The same instructions apply: : Some tasks can be solved with one si..."
imported>Hendrik Brummermann
No edit summary
Line 10: Line 10:


== Example ==
== Example ==

The itemids and names of all items that have been touched by alice and malice in the last two days?


<source lang="sql">
SELECT DISTINCT i3.itemid, i3.param1
FROM itemlog As i1, itemlog As i2, itemlog i3
WHERE i1.itemid = i2.itemid AND i1.itemid = i3.itemid
AND i1.source = 'alice' AND i2.source='malice' AND i3.event = 'register'
AND i1.timedate > '2011-09-11' AND i2.timedate > '2011-09-11'
ORDER BY i1.param1
</source>

(Assuming today is 2011-09-14)