ITEC 3220 Lecture 1: Structured Query Language EXAMPLES
Document Summary
Query expression evaluation: evaluated from left to right, subexpression in brackets are evaluated first, nots before and and or, and before or. Patter match: like, whether string matches a specified pattern. Select procedure: compute cross-product, count in the qualification, delete column that are not in select-list. Use it for less than or greater than use theta join. Natural join: if you have common field, they could be connected only using equality condition. If there are more than one equality condition applied to all queries. Example: find all the students who were born in or before 1980. Select distinct t. sid from transcript t,course c where t. cid = c. cid and c. pcode = itec": find the names and ids of students who have been registered in itec program. Select distinct s. sid, s. name, from student s join transcript t on s. sid = t. sid join course c. We don"t do distinct here because one student might have more itec courses needs to be increased also.