How to change the name of a column in a select in the database?

Asked

Viewed 5,648 times

2

I am making a database for a college activity and was asked to display the table by changing the name of attributes(columns) to "Nome do Cliente" and "Endereco do Cliente". How can I do that?

Example:

Tabela: nome         >       Saída: Nome do Cliente
Tabela: endereço     >       Saída: Endereço do Cliente
  • 1

    You want to change the name of the columns that are returned in your query?

2 answers

7


Although your question is not clear enough, I believe that’s what you want:

SELECT nome AS 'Nome do Cliente', endereço AS 'Endereco do Cliente' FROM clientes

The AS causes you to rename the column displayed in SELECT, but do not confuse, it only changes the name in the select display, it does not change the table.

See working n Sqlfiddle.

  • 1

    good, I think that’s right! But who will know ...

  • That’s right. I was complicating something simple.

  • @Mateusborges Could you then mark my answer as correct? This helps maintain the organization of the site and also for those who have the same problem in the future.

2

It is possible yes, but when consulting the names of the columns should be involved with ` (crase sign)

See the following examples:

Right:

inserir a descrição da imagem aqui

The incorrect:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.