## Querying the Database with SQL

    select [field names]
    from   [table name]
    where  [condition]

### Selecting Fields from a Course

SQL Input:

    select
        cat_num, department_short, num_int, title, faculty_text
    from
        courses
    where
        cat_num = 22304

    mysql> select cat_num, department_short, num_int, title, faculty_text  from courses where cat_num = 22304 ;
    +---------+------------------+---------+--------------------------------------+-------------------------+
    | cat_num | department_short | num_int | title                                | faculty_text            |
    +---------+------------------+---------+--------------------------------------+-------------------------+
    |   22304 | Astronomy        |      17 | Galactic and Extragalactic Astronomy | Daniel James Eisenstein |
    +---------+------------------+---------+--------------------------------------+-------------------------+
    1 row in set (0.01 sec)

### Selecting List of Departments

SQL Input:

    select distinct department_code, department_short from courses

Terminal Output:

    mysql> SELECT distinct department_code, department_short FROM courses order by department_short ;
    +-----------------+----------------------------------------------------------+
    | department_code | department_short                                         |
    +-----------------+----------------------------------------------------------+
    | AAAS            | African and African American Studies                     |
    | AMER            | American Studies                                         |
    | ANTH            | Anthropology                                             |
    | URBP            | Architecture, Landscape Architecture, and Urban Planning |
    | ABEA            | Asian Studies Programs                                   |
    | ASTR            | Astronomy                                                |
    | BSDM            | Biological Sciences in Dental Medicine                   |
    | BSPH            | Biological Sciences in Public Health                     |
    | BIPH            | Biophysics                                               |
    | BIST            | Biostatistics                                            |
    | CELT            | Celtic Languages and Literatures                         |
    | CHPB            | Chemical and Physical Biology                            |
    | CHBI            | Chemical Biology                                         |
    | CHEM            | Chemistry and Chemical Biology                           |
    | CPLT            | Comparative Literature                                   |
    | DRAM            | Dramatic Arts                                            |
    | E&PS            | Earth and Planetary Sciences                             |
    | EALC            | East Asian Languages and Civilizations                   |
    | ECON            | Economics                                                |
    | DEAS            | Engineering and Applied Sciences                         |
    | ENGH            | English                                                  |
    | ESPP            | Environmental Science and Public Policy                  |
    | EXPO            | Expository Writing                                       |
    | FOLK            | Folklore and Mythology                                   |
    | FRSP            | Freshman Seminars                                        |
    | GEN ED          | General Education                                        |
    | GERM            | Germanic Languages and Literatures                       |
    | GLOBHLTH        | Global Health and Health Policy                          |
    | GOVM            | Government                                               |
    | HPOL            | Health Policy                                            |
    | HIST            | History                                                  |
    | HLIT            | History and Literature                                   |
    | HAA             | History of Art and Architecture                          |
    | HSCI            | History of Science                                       |
    | HSEM            | House Seminars                                           |
    | HEB             | Human Evolutionary Biology                               |
    | HUM             | Humanities                                               |
    | LSCI            | Life Sciences                                            |
    | LING            | Linguistics                                              |
    | MATH            | Mathematics                                              |
    | MDSC            | Medical Sciences                                         |
    | MDST            | Medieval Studies                                         |
    | MEST            | Middle Eastern Studies                                   |
    | MBB             | Mind, Brain, and Behavior                                |
    | MCB             | Molecular and Cellular Biology                           |
    | MUSC            | Music                                                    |
    | NELC            | Near Eastern Languages and Civilizations                 |
    | NEURO           | Neurobiology                                             |
    | NODEPT          | No Department                                            |
    | BIOE            | Organismic and Evolutionary Biology                      |
    | PHIL            | Philosophy                                               |
    | PSCI            | Physical Sciences                                        |
    | PHYS            | Physics                                                  |
    | PSYC            | Psychology                                               |
    | RSEA            | Regional Studies - East Asia                             |
    | ROML            | Romance Languages and Literatures                        |
    | REECA           | Russia, Eastern Europe, and Central Asia                 |
    | SLAV            | Slavic Languages and Literatures                         |
    | SPOL            | Social Policy                                            |
    | SOST            | Social Studies                                           |
    | SOCL            | Sociology                                                |
    | SAST            | South Asian Studies                                      |
    | SPCN            | Special Concentrations                                   |
    | STAT            | Statistics                                               |
    | SCRB            | Stem Cell and Regenerative Biology                       |
    | WMGS            | Studies of Women, Gender, and Sexuality                  |
    | SBIO            | Systems Biology                                          |
    | CLAS            | The Classics                                             |
    | RELG            | The Study of Religion                                    |
    | UKRA            | Ukrainian Studies                                        |
    | VES             | Visual and Environmental Studies                         |
    +-----------------+----------------------------------------------------------+
    71 rows in set (0.00 sec)