此查詢應該返回4行,但隨着62983.任何理由ID返回1?MySQL和正則表達式對INT
SELECT *
FROM sims_user_role_maps surm
JOIN sims_role sr ON surm.role_id = sr.id
WHERE
surm.user_id = 118730
AND sr.organization_id REGEXP 62978|62981|62982|62983
SP呼叫
call schools_remove_for_user('f155ec0e-b9ce-11e1-a1fa-001cc4565d26', '62966|62969|62983')
SP
CREATE PROCEDURE `schools_remove_for_user`(
user_id NVARCHAR(255),
school_ids LONGTEXT
)
BEGIN
DECLARE sims_user_id INT DEFAULT NULL;
SELECT u.sims_id
INTO sims_user_id
FROM user u
WHERE u.id = user_id;
SET SQL_SAFE_UPDATES = 0;
DELETE FROM sims_user_role_maps
WHERE
user_id = sims_user_id
AND role_id IN (
SELECT role_id
FROM(
SELECT surm.role_id
FROM sims_user_role_maps surm
JOIN sims_role sr ON surm.role_id = sr.id
WHERE
surm.user_id = sims_user_id
AND sr.organization_id REGEXP school_ids)
A);
END
你確定那些其他行存在嗎? 78,81,82?在surm表中有一個user_id = 118730? – MJB 2012-07-16 18:53:45
這是一個動態字符串,是的,他們屬於該用戶ID。我甚至刪除了最後一個ID 62983,並且它仍然只返回那一行。 – 2012-07-16 18:55:07