Home > Blockchain >  Get a tuple from Postgres as result using asterisk .* notation
Get a tuple from Postgres as result using asterisk .* notation

Time:01-11

If I use the below code:

SELECT
    (player.id, player.firstname, player.lastname) AS player,
FROM
  player

I get this result:

 ---------------- 
| player         |
 ---------------- 
| (1,Bob,Smith)  |
 ---------------- 
| (2,John,Smith) |
 ---------------- 

I like it!

But I wanna use player.* instead of indicating each field.

I tried with:

SELECT
    (player.*) AS player,
FROM
  player

but the result is not like before: there are columns like:

 ---- ----------- ---------- 
| id | firstname | lastname |
 ---- ----------- ---------- 
| 1  | Bob       | Smith    |
 ---- ----------- ---------- 
| 2  | John      | Smith    |
 ---- ----------- ---------- 

Why? Is there a way to get a tuple with all the columns using player.*?

CodePudding user response:

Use the table reference:

select player
from player;
  • Related