Jeremy Milarsky's blog

Flying with SQL subqueries

In most cases, when you want to match data from one table in a database to another, a common approach is to use a JOIN clause in your query.

For example, if you had a list of candidates in one table, and a list of donations made to candidates (with one field having a candidate ID in it), you'd probably either use JOIN clause or a WHERE clause to match them together:

(pseudo-code)

SELECT * FROM candidates, donations where candidates.candidate_id = donations.candidate_id;

Death and the UNION clause

Sometimes we need to get information from a database where the information is, for whatever reason, not stored in one table but broken into smaller tables with an identical structure. A good example of this is our Social Security Administration Death Master file.

Advertise in Uplink

IRE logo

The National Institute for Computer-Assisted Reporting is a joint program of
Investigative Reporters and Editors, Inc., and the Missouri School of Journalism.

141 Neff Annex, Missouri School of Journalism, Columbia MO, 65211, Tel. 573-882-2042, Fax 573-884-5544

All Rights Reserved