2010-03-15 13 views
0

是否可以使用Postgresql類似於以下內容而不使用函數?使用exec函數從頭開始查詢?

僞SQL碼:

SELECT * FROM sometable其中somecol = someValue中AND someothercol IN EXEC( '選擇exclusionlist東西')

我的主要目的是建立與預定義的查詢表在where子句中調用

僞sql代碼: select * from sometable wherecol = somevalue AND someothercol IN exec(從預定義的查詢中選擇查詢,其中id = someid)

回答

1

至於我能看到的唯一選擇是:

prepare my_usr_id as select usr_id from usr where usr_id < $1; 
create temp table my_temp on commit drop as execute my_usr_id(10); 
select * from usr join my_temp using (usr_id); 
+0

謝謝你,真是個不錯的建議,比我在我的問題想通了,更 – 2010-03-17 23:09:05