Thread: FROM Clause subquery
Hi All
I have problems on 'from clause subquery'.
test=# create sequence test_seq;
test=# select * from test_seq
Result:
sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called
---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
test_seq | 1 | 1 | 9223372036854775807 | 1 | 1 | 1 | f | f
(1 row)
---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
test_seq | 1 | 1 | 9223372036854775807 | 1 | 1 | 1 | f | f
(1 row)
Now I want to get sequence fields following:
test=# select * from (select relname from pg_class where relkind='S') as foo;
My Result:
relname
-------------------------
test_seq
(1 rows)
-------------------------
test_seq
(1 rows)
Why? FROM Clause subquery not working? or my mistakes?
Help Me!
Bye.
select * from (select relname from pg_class where relkind='S') as foo; relname --------------------------------- user_seq util_seq reftable_seq apps_seq acl_seq message_seq problem_seq customer_seq service_seq job_schedule_schedule_id_seq scheduling_ru_sched_rule_id_seq time_units_tu_id_seq data_types_data_type_id_seq counter expertise_exp_expertise_id_seq grades_grd_grade_id_seq occupation_occ_occupation_i_seq personnel_psl_employee_id_seq vacations_vac_period_id_seq package_package_id_seq builder_builder_id_seq pricetype_pricetype_id_seq price_price_id_seq actions_action_id_seq wot_list_wot_id_seq wot_task_types_wot_task_id_seq tt_task_types_tt_task_type__seq tt_task_mater_tt_task_mater_seq tasks_task_id_seq fl_up_results_flup_res_id_seq follow_ups_fl_up_id_seq wo_log_wo_log_id_seq wo_comments_wo_comments_id_seq Works for me dev=> select version(); version ----------------------------------------------------------- PostgreSQL 7.2 on i686-pc-linux-gnu, compiled by GCC 2.96 I just cut and pasted your query. If you mean why is it returning just the name of the sequence then it is because that is all you are asking for in the sub query Darren Ferguson On Mon, 11 Mar 2002, DongSoo Song wrote: > Hi All > > I have problems on 'from clause subquery'. > > test=# create sequence test_seq; > test=# select * from test_seq > > Result: > > sequence_name | last_value | increment_by | max_value | min_value | cache_value | log_cnt | is_cycled | is_called > ---------------+------------+--------------+---------------------+-----------+-------------+---------+-----------+----------- > test_seq | 1 | 1 | 9223372036854775807 | 1 | 1 | 1 | f | f > (1 row) > > Now I want to get sequence fields following: > > test=# select * from (select relname from pg_class where relkind='S') as foo; > > My Result: > > relname > ------------------------- > test_seq > (1 rows) > > Why? FROM Clause subquery not working? or my mistakes? > > Help Me! > > Bye. > >
> Now I want to get sequence fields following: > > test=# select * from (select relname from pg_class where relkind='S') as foo; > > My Result: > > relname > ------------------------- > test_seq > (1 rows) > > Why? FROM Clause subquery not working? or my mistakes? That's not what the above does. The subselect in from isn't a substitute for table names, it's a substitute for a table. Think of it almost as an inplace view definition.