SELECT title, instructor FROM Class WHERE dept = 'CS';
If we want to remove duplicates, we need to add DISTINCT
after SELECT
SELECT DISTINCT * FROM Enroll;
# ^ those commands are actually case-insensitive, but the name of the tables are not
SELECT DISTINCT name, GPA # distinct will only remove duplicates for the selected tuple
FROM Enroll E,Student S # join Enroll and Student and rename the column name
WHERE dept='CS' AND E.sid=S.sid;
SELECT name, GPA
FROM Student
WHERE addr LIKE '%Wilshire%';
# LIKE: instead of interpreting as a regular string, interpret them as string with
# special commands
# % : string with any length
# _ : one character
2 queries are logical equivalent if and only if the 2 queries returns exactly the same tuples under any database instances