Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.*?

>Solution :

Use the table reference:

select player
from player;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading