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 picks columns
Choosing columns keeps only the fields you name.
Select only the name and score columns from student, in that order.
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。
Select name and score, but rename the headings to pupil and mark using AS.
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。