如何将特定 SELECT 命令与更新结合 - SQL

How to combine specific SELECT command with UPDATE - SQL

我需要更新我的 SQL 数据库中某些特定 table 的列。

我有一个 SELECT 命令,它选择所有正确的 tables 但我不知道我应该如何将它与更新结合起来(我是一个完整的菜鸟)。

SELECT
  c.id_customer AS id_customer,
  id_gender,
  firstname,
  lastname,
  c.email AS email,
  birthday,
  date_add,
  c.active AS active,
  c.*,
  a.id_group
FROM prstshp_customer_group a
LEFT JOIN prstshp_customer c
  ON (a.id_customer = c.id_customer)
WHERE 1
AND a.id_group = 4
AND c.deleted != 1
AND c.id_shop IN (1)
ORDER BY id_group ASC

我必须更新 table prstshp_customer 中名为 id_default_group 的列,在 table [=15] 中选择特定条目的值为“4” =] table.

使用update join

update prstshp_customer
join
(
SELECT
  c.id_customer AS id_customer,
  id_gender,
  firstname,
  lastname,
  c.email AS email,
  birthday,
  date_add,
  c.active AS active,
  a.id_group
FROM prstshp_customer_group a
LEFT JOIN prstshp_customer c
  ON (a.id_customer = c.id_customer)
WHERE 1
AND a.id_group = 4
AND c.deleted != 1
AND c.id_shop IN (1)
)B on prstshp_customer.id_customer=B.id_customer
SET id_default_group=4