Choosing columns · Выбор столбцов
Picking columns
SELECT * returns every column. Usually you want only a few. Instead of *, list the columns you want, separated by commas:
The result has just those columns, in the order you wrote them.
Выбор столбцов
SELECT * возвращает все столбцы. Обычно вам нужны лишь несколько. Вместо * перечислите нужные столбцы, разделяя их запятыми:
SELECT name, score FROM student;
Результат будет содержать только эти столбцы в том порядке, в котором вы их написали.
Renaming a column with AS
You can rename a column in the result with AS. This does not change the table — only the heading shown:
The headings become pupil and mark. This is handy for clear reports.
Переименование столбца с помощью AS
Вы можете переименовать столбец в результате с помощью оператора AS. Это не изменяет саму таблицу — только заголовок, который отображается:
SELECT name AS pupil, score AS mark FROM student;
Заголовки становятся pupil и mark. Это удобно для создания понятных отчетов.
Common mistakes
- List the columns you want, separated by commas.
ASrenames a column in the result.
Частые ошибки
- Перечислите нужные столбцы, разделяя их запятыми.
ASпереименовывает столбец в результате.
SELECT picks columns · SELECT выбирает столбцы
Choosing columns keeps only the fields you name. · Выбор столбцов оставляет только указанные вами поля.
Select only the name and score columns from student, in that order. · Выберите только столбцы name и score из таблицы student, в указанном порядке.
Click Run to see the output here. · Нажмите Запустить, чтобы увидеть результат здесь.
Select name and score, but rename the headings to pupil and mark using AS. · Выберите name и score, но переименуйте заголовки в pupil и mark, используя AS.
Click Run to see the output here. · Нажмите Запустить, чтобы увидеть результат здесь.