How to select multiple columns using the table prefix only once?

5

In the relational model condition, I have to specify the table prefix, am I right?

Example: SELECT c.nome, c.idade, a.nome, a.idade FROM ...

What I wanted to know is if you can not do something like this:

SELECT c(nome, idade), a(nome, idade) FROM ...

Can you give this "streamlined" code, or is it the only way to prefix everything?

    
asked by anonymous 23.03.2017 / 20:59

1 answer

2

The best solution to your problem will really be the field-by-field statement with your due Alias .

Obviously you can use the wildcard * character, consider the syntax:

  

[PREFIX]. * or
  [TABLE NAME]. *

Whereas ALL fields will be invoked, your case would look like this:

SELECT c.*, a.* FROM...

Using Table Aliases

"The readability of a SELECT statement can be improved by assigning an alias to a table, which is also known as correlation name or range variable .A table alias can be assigned with or without the AS keyword:

table_name AS table alias
table_name table_alias

Obs. If an alias is assigned to a table, all explicit references to the table in the Transact-SQL statement will need to use the alias; not the table name. "

Some correlated posts

SQL Prefix Prefixes
#

    
24.03.2017 / 13:02