Choosing columns · Escolhendo colunas
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.
Selecionando colunas
SELECT * retorna todas as colunas. Geralmente você quer apenas algumas. Em vez de *, liste as colunas desejadas, separadas por vírgulas:
SELECT name, score FROM student;
O resultado contém apenas essas colunas, na ordem em que foram escritas.
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.
Renomeando uma coluna com AS
Você pode renomear uma coluna no resultado usando AS. Isso não altera a tabela — apenas o cabeçalho exibido:
SELECT name AS pupil, score AS mark FROM student;
Os cabeçalhos se tornam pupil e mark. Isso é útil para relatórios claros.
Common mistakes
- List the columns you want, separated by commas.
ASrenames a column in the result.
Erros comuns
- Liste as colunas desejadas, separadas por vírgulas.
ASrenomeia uma coluna no resultado.
SELECT picks columns · SELECT escolhe colunas
Choosing columns keeps only the fields you name. · Escolher colunas mantém apenas os campos que você nomeia.
Select only the name and · e score columns from student, in that order. · Selecione apenas as colunas name e score de student, nesta ordem.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.
Select name and · e score, but rename the headings to pupil and · e mark using AS. · Selecione name e score, mas renomeie os cabeçalhos para pupil e mark usando AS.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.