PostgreSQL使用变量

时间:2019-12-06 10:09:50

标签: sql postgresql

Select item_pk_id from item where upc='7300156576798';  
61564
Delete from price where item_pk_id='61564';
Delete from item where upc='7300156576798';

61564来自第一个查询,是否可以简化此过程,所以我只需要在顶部输入UPC作为变量? 现在,我必须运行所有3个查询。

像这样

SET x = '7300156576798'
y = Select item_pk_id from item where upc= x;
Delete from price where item_pk_id=y;
Delete from item where upc=x;

此命令在SQL编辑器/ postgresql #postgresql中运行,以从大型数据库中删除som项目。

0 个答案:

没有答案