CMPS 002 - Computer Literacy

Prof. Paulo Franca

CyberSlug Rules!

Classes

Class Syllabus

Grading Policy

Labs

Interact

Login

  • enter system
  • get attendance
  • submit work
  • take lab quiz
  • check scores

Help

Help me!

Links

Staff only

 

 

 

Datacare   Ahshay

 

SQL - Structure Query Language

  • used to manipulate most databases existing today
  • highly standard, but few differences depending on manufacturer

Operations:

select - allows you to select a set of fields from one or more tables according to a specific criteria. Refer to the sample tables for the examples.

Example 1: Select fields from one table:

select <list of fields> from <table>

select name,college from students

select name,department from instructor

Example 2: Now, you can filter to narrow your results:

select <list of fields> from <table> where <condition>

select name,collge from students where college='Merrill'

Example 3: You can also join one table to another and select from the result:

select <list of fields> from <table> left join <other table> on <matching condition>

select name,coursecode from students left join enrollment on students.studentid=enrollment.studentid

Notice that you may have to use the table name to qualify fields that have the same name.

Example 4: You can also sort the results by one or more fields:

order by <list of fields>

select name,coursecode from students left join enrollment on students.studentid=enrollment.studentid order by coursecode,name

Example 5: You can also have a field that "count" the records

count(*)

select count(*) from classes

select coursecode,count(*) from classes group by coursecode