pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Cursor need it? 2+ messages / 2 participants [nested] [flat]
* Cursor need it? @ 2005-06-08 14:44 Lucas Hernndez <lucashdz@gmail.com> 0 siblings, 0 replies; 2+ messages in thread From: Lucas Hernndez @ 2005-06-08 14:44 UTC (permalink / raw) To: pgsql-sql I am a new postgres user I want to get a list of tables from pg_tables where tables are like ‘%wo%’ (for example).. and then query that list …. Select count(*) from tableVARIABLENAMEFROMFIRSTQUERY In SQL SERVER I can do that using cursor but in postgresql I don’t understand how to use cursors Here is what I am trying to do for each table on the list Select tablename, count(*) tables from ( list of tables) tablename tables table1 25 table2 35 Any Idea would be appreciated Thanks Lucas ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Cursor need it? @ 2005-06-08 15:23 KÖPFERL Robert <robert.koepferl@sonorys.at> 0 siblings, 0 replies; 2+ messages in thread From: KÖPFERL Robert @ 2005-06-08 15:23 UTC (permalink / raw) To: pgsql-sql | |I am a new postgres user | |I want to get a list of tables from pg_tables where tables are like |‘%wo%’ (for example).. and then query that list …. | |Select count(*) from tableVARIABLENAMEFROMFIRSTQUERY | |In SQL SERVER I can do that using cursor but in postgresql I don’t |understand how to use cursors Sorry, but this is a SQL-Server. You are looking for cross table joins. Join the pg_class table (where you get the table name) with another table which you want to query additional data. Then select your columns off both tables. select p.name, m.foo from pg_class p JOIN myinfo m ON p.name=m.info this is equal to select p.name, m.foo from pg_class p, myinfo m where p.name=m.info | |Here is what I am trying to do |for each table on the list |Select tablename, count(*) tables from ( list of tables) | |tablename tables |table1 25 |table2 35 | |Any Idea would be appreciated | |Thanks | |Lucas | | |---------------------------(end of |broadcast)--------------------------- |TIP 2: you can get off all lists at once with the unregister command | (send "unregister YourEmailAddressHere" to |majordomo@postgresql.org) | ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-06-08 15:23 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2005-06-08 14:44 Cursor need it? Lucas Hernndez <lucashdz@gmail.com> 2005-06-08 15:23 Re: Cursor need it? KÖPFERL Robert <robert.koepferl@sonorys.at>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox