在PosgreSQL上,我有一个披萨餐厅的数据库。使用此代码:
SELECT command.id_command, array_agg(history_state_of_command.state)
FROM command JOIN history_state_of_command
ON command.id_command = history_state_of_command.id_command
GROUP BY command.id_command
我获得这些结果,并带有命令的ID和命令的相关状态:
command.id_command命令状态
1“ {Pizza_Order,Pizza_in_preparation,Pizza_prepared,Pizza_ready_for_delivery,Pizza_delivering,Pizza_deliver}”
2“ {Pizza_Order,Pizza_in_preparation}”
3“ {Pizza_Order,Pizza_in_preparation,Pizza_prepared,Pizza_ready_for_delivery,Pizza_delivering,Pizza_deliver,”命令已取消“}”]“>
4“ {Pizza_Order,Pizza_in_preparation,Pizza_prepared,Pizza_ready_for_delivery,Pizza_delivering,Pizza_deliver}”
我想找到一个SQL代码,在其中我仅获得从未准备过披萨的命令的ID:command.id_command命令状态2“ {Pizza_Order,Pizza_in_preparation}”
非常感谢您的帮助!
在PosgreSQL上,我有一个披萨餐厅的数据库。使用以下代码:SELECT command.id_command,array_agg(history_state_of_command.state)FROM命令JOIN history_state_of_command ON ...
您可以使用相关的子查询来找到此命令: