声明设置某些课程直播和一些起草

Statement to set certain courses live and some to draft

我是一名非常初级的 Laravel 开发人员,我需要帮助更改一些 "courses"。

今晚我需要将table“courses”内的所有课程与“draft”的“status”设置为“published” ”以及他们的雕像不是“draft”到“draft”的所有课程。

他们的状态可以是:

"full"
"published"
"limited"
"cancelled"
"archived"
"inactive"

有人可以帮忙吗?

试试这个查询:

UPDATE courses
SET status = CASE WHEN status = 'draft' THEN 'published' ELSE 'draft' END

在此特定实例中,我们不需要使用 WHERE 子句,因为您打算更新 table.

中的每条记录