/* set default priority */
UPDATE qna_table
SET priority = 0;

/* set STATE_RELABELLING questions priority to be 0(highest) */
UPDATE qna_table
SET priority = 1
FROM
(SELECT id FROM qna_state_table WHERE name = 'STATE_RELABELLING') AS state_relabelling
WHERE state_id = state_relabelling.id;
