Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eaUFl-0003KP-Kv for pgsql-sql@arkaria.postgresql.org; Sat, 13 Jan 2018 22:26:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eaUFl-0003q3-7R for pgsql-sql@arkaria.postgresql.org; Sat, 13 Jan 2018 22:26:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eaUFl-0003pt-1K for pgsql-sql@lists.postgresql.org; Sat, 13 Jan 2018 22:26:17 +0000 Received: from mta04.2.doruk.net.tr ([81.21.172.141] helo=mta04.doruk.net.tr) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eaUFe-00036X-0n for pgsql-sql@postgresql.org; Sat, 13 Jan 2018 22:26:16 +0000 Received: from cmail19.webkontrol.doruk.net.tr ([212.58.6.99]) by mta04.doruk.net.tr with esmtp (Exim 4.86) (envelope-from ) id 1eaUF9-0003JP-CH for pgsql-sql@postgresql.org; Sun, 14 Jan 2018 01:25:39 +0300 Received: from DESKTOPM80CG12 ([94.122.16.162]) by cmail19.webkontrol.doruk.net.tr (IceWarp 11.1.2.0) with ASMTP id 201801140126404223 for ; Sun, 14 Jan 2018 01:26:40 +0300 From: =?iso-8859-9?B?RXJ0YW4gS/zn/Gtv8Gx1?= To: Subject: Alternative SQL Date: Sun, 14 Jan 2018 01:26:07 +0300 Message-ID: <000201d38cbd$8197c070$84c74150$@1nar.com.tr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-9" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdOMuF4zPHQ5B8D1QKWExAqyZ2ZVrQ== Content-Language: tr List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, I am using PostgreSQL 10.1 64bit on Windows 10 x64 system. My database have following tables in it: robox=3D# \dt List of relations Schema | Name | Type | Owner --------+---------------------+-------+------- public | aciliskapanis | table | robox public | ameliyathaneler | table | robox public | ameliyatlar | table | robox public | errorlog | table | robox public | guncellemetablolari | table | robox public | hastalar | table | robox public | kaphareketleri | table | robox public | kullanici | table | robox public | malzemeler | table | robox public | params | table | robox public | personel | table | robox public | sayimbaslik | table | robox public | sayimdetay1 | table | robox public | sayimdetay11 | table | robox public | sayimdetay12 | table | robox public | sayimdetay2 | table | robox public | sayimdetay3 | table | robox public | sayimmakinalari | table | robox public | sayimyazdir | table | robox public | sifirlamalar | table | robox public | updates | table | robox (21 rows) I am using following SQL: select 'aciliskapanis', max(kayitzamani) from aciliskapanis where serino = =3D '00000000de7de681' union select 'sayimbaslik', max(kayitzamani) from sayimbaslik where serino =3D '00000000de7de681' union select 'sayimdetay1', max(kayitzamani) from sayimdetay1 where serino =3D '00000000de7de681' union select 'sayimdetay11', max(kayitzamani) from sayimdetay11 where serino = =3D '00000000de7de681' union select 'sayimdetay12', max(kayitzamani) from sayimdetay12 where serino = =3D '00000000de7de681' union select 'sayimdetay2', max(kayitzamani) from sayimdetay2 where serino =3D '00000000de7de681' union select 'sayimdetay3', max(kayitzamani) from sayimdetay3 where serino =3D '00000000de7de681' union select 'errorlog', max(kayitzamani) from errorlog where serino =3D '00000000de7de681' union select 'kaphareketleri', max(kayitzamani) from kaphareketleri where = serino =3D '00000000de7de681' union select 'sifirlamalar', max(kayitzamani) from sifirlamalar where serino = =3D '00000000de7de681' Above SQL gives me following result and this is what I wanted.=20 ?column? max sayimdetay2 2018-01-13 23:24:29 errorlog 2018-01-14 00:08:56 sayimbaslik 2018-01-14 00:10:36 sifirlamalar 2018-01-13 23:19:07 sayimdetay11 2018-01-13 23:15:58 sayimdetay1 2018-01-14 00:10:42 sayimdetay3 2018-01-13 23:19:20 aciliskapanis 2018-01-14 00:12:44 sayimdetay12 2018-01-14 00:13:11 kaphareketleri 2018-01-14 00:13:33 But, it is not dynamic. Meaning, I am not using information in guncellemetablolari table. guncellemetablolari table holds table names = as records that needs to be queried in my database. These records may = change in time. What I would like is an SQL (not a database function, if possible) which gives me same result as above using records in guncellemetablolari where guncellenir column is false.=20 robox=3D# \dS guncellemetablolari; Table "public.guncellemetablolari" Column | Type | Modifiers -------------+---------+----------- adi | text | not null guncellenir | boolean | Indexes: "guncellemetablolari_pkey" PRIMARY KEY, btree (adi) robox=3D# select * from guncellemetablolari; adi | guncellenir ----------------+------------- ameliyatlar | t hastalar | t malzemeler | t personel | t aciliskapanis | f sayimbaslik | f sayimdetay1 | f sayimdetay11 | f sayimdetay2 | f sayimdetay3 | f sayimyazdir | f errorlog | f kaphareketleri | f sifirlamalar | f sayimdetay12 | f (15 rows) Any help is appreciated. Thanks & regards, Ertan K=FC=E7=FCko=F0lu