Very Easy
Select specific columns II
Select the student_id
and class_code
columns from the students
table.
TABLES
students
+------------+------------+-----------+-----+------------+
| student_id | first_name | last_name | age | class_code |
+------------+------------+-----------+-----+------------+
| 1 | Mike | Chaplin | 12 | 7A |
| 2 | Emily | Jackson | 12 | 7A |
| 3 | Robert | Jackson | 12 | 7A |
| ... | ... | ... | ... | ... |
+------------+------------+-----------+-----+------------+
EXPECTED OUTPUT
+------------+------------+
| student_id | class_code |
+------------+------------+
| 1 | 7A |
| 2 | 7A |
| 3 | 7A |
| ... |... |
+------------+------------+
To select specific columns from a table, you need to state each column's name in the SELECT
statement. For example, if you wanted to select only the columns col1
and col2
from a table table1
, you'd write:
SELECT
col1,
col2
FROM table1
SELECT
student_id,
class_code
FROM students