select 'id' in every table psqlPosted: - Source : stackoverflow
Each table in my database (see schema) has a primary key called
I would like to find all records in all tables where id is in the range [1,1000]. How can I write such a query?
I've tried to write a for loop following the PostgreSQL docs
FOR T IN ( SELECT TABLE_NAME FROM information_schema. TABLES WHERE table_schema = 'public' ) LOOP SELECT id, T FROM T WHERE ID BETWEEN 1 AND 1000; RETURN NEXT T; END LOOP ;
but get "Syntax error at FOR".