Jump to content

User:Leucosticte/SQL attempts

From mediawiki.org

What I am trying to do is get two results -- the one revision in the revision table that has rev_page=5, and the one revision in the archive table that has ar_title='Boocoo'. These attempts have failed:

<source lang="sql"> -- 1 result (rev_page = 5; archive fields null) SELECT * FROM revision LEFT OUTER JOIN archive ON revision.rev_page=archive.ar_page_id WHERE revision.rev_page=5 OR archive.ar_title='Boocoo'

-- 1 result (rev_page = 5; archive fields null) SELECT * FROM revision LEFT JOIN archive ON revision.rev_page=archive.ar_page_id WHERE revision.rev_page=5 OR archive.ar_title='Boocoo'

-- 1 result (revision fields null; ar_title = Boocoo SELECT * FROM revision RIGHT JOIN archive ON revision.rev_page=archive.ar_page_id WHERE revision.rev_page=5 OR archive.ar_title='Boocoo'

-- 110 results (all the results in the revision table) SELECT * FROM revision LEFT OUTER JOIN archive ON revision.rev_page=5 OR archive.ar_title='Boocoo'

-- 110 results (all the results in the revision table) SELECT * FROM revision LEFT OUTER JOIN archive ON archive.ar_title='Boocoo'

-- 110 results (all the results in the revision table) SELECT * FROM revision LEFT OUTER JOIN archive ON archive.ar_title='Boocoo' AND revision.rev_page=5

-- 110 results (all the results in the revision table) SELECT * FROM archive, revision WHERE revision.rev_page=5 OR ar_title='Boocoo'

-- 1 result SELECT * FROM archive, revision WHERE revision.rev_page=5 AND ar_title='Boocoo'

-- 0 results SELECT * FROM revision JOIN archive ON revision.rev_page=archive.ar_page_id WHERE revision.rev_page=5 OR archive.ar_title='Boocoo'

-- 0 results SELECT * FROM revision INNER JOIN archive ON revision.rev_page=archive.ar_page_id WHERE revision.rev_page=5 OR archive.ar_title='Boocoo'

-- 0 results SELECT * FROM revision CROSS JOIN archive ON revision.rev_page=archive.ar_page_id WHERE revision.rev_page=5 OR archive.ar_title='Boocoo'