|
CMPS 002 - Computer Literacy Prof. Paulo Franca |
|
CyberSlug Rules! ClassesClass Syllabus Labs
Interact
HelpLinks
|
SQL - Structure Query Language
Operations:
Example 1: Select fields from one table:
select name,college from students select name,department from instructor Example 2: Now, you can filter to narrow your results:
select name,collge from students where college='Merrill' Example 3: You can also join one table to another and select from the result:
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:
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
select count(*) from classes select coursecode,count(*) from classes group by coursecode |