2024年4月15日发(作者:)
--------+----------------+-----------
item | inventory_item |
count | integer |
postgres=# select item from on_hand ;
item
------------------------
("fuzzy dice",42,1.99)
(Apple,22,4.4)
(Apple,22,4.4)
(Apple,22,4.4)
(Orange,22,55)
(Orange1,22,66)
(6 rows)
postgres=# select (item).name from on_hand where (item).price >10;
name
---------
Orange
Orange1
(2 rows)
postgres=# select (item).name from on_hand ;
name
------------
fuzzy dice
Apple
Apple
Apple
Orange
Orange1
(6 rows)
postgres=# select (on_).name from on_hand where (on_).price > 10;
name
---------
Orange
Orange1
(2 rows)
select just one field from the result of a function that returns a composite value,you'd need to
write something like:
select (my_func(...)).field from table_name;
postgres=# create table complex_col (col complex);
CREATE TABLE
postgres=# insert into complex_col values ((1.1,2.2));
INSERT 0 1
postgres=# insert into complex_col (col.r,col.i) values (8.8,9.9);
INSERT 0 1
postgres=# select * from complex_col ;
col
-----------
(1.1,2.2)
(8.8,9.9)
(2 rows)


发布评论