In these lessons, we learned the following queries:
- SELECT NAME_LAST FROM People
- SELECT NAME_LAST, NAME_FIRST FROM People
- SELECT * FROM People
- SELECT * FROM People WHERE ID = 'tjones'
- SELECT * FROM People WHERE NAME_LAST LIKE 'S%'
- SELECT * FROM People WHERE POSITION LIKE '%n'
- SELECT * FROM People WHERE ID LIKE '%smi%'
- SELECT * FROM People WHERE NAME_LAST = 'Jones' AND POSITION = 'Manager'
- SELECT * FROM People WHERE NAME_LAST = 'Jones' OR POSITION = 'Manager'
- SELECT * FROM People WHERE (NAME_LAST = 'Jones' OR NAME_LAST = 'Smith') AND POSITION = 'Manager'
- SELECT ID, NAME_LAST FROM People WHERE NAME_LAST BETWEEN 'Madison' AND 'Williamson'
- SELECT ID, NAME_LAST FROM People WHERE NAME_LAST NOT BETWEEN 'Madison' AND 'Williamson'
- SELECT DISTINCT POSITION FROM People
- SELECT ID, POSITION FROM People ORDER BY ID
- SELECT POSITION, NAME_LAST FROM People ORDER BY POSITION, NAME_LAST
- SELECT POSITION, NAME_LAST FROM People ORDER BY POSITION DESC
Practice all of these concepts on a different table. You may cut and paste from the list above. Be sure to adjust the table name and field names accordingly.
Then, take a test.
Note: If you have data in two separate tables, you can join the data together to act as if it were one table. When joining tables, or just when selecting data from different tables, field names may be the same from each table, which may make selecting them difficult. In this case, use aliases.
For more on SQL, see Guru99