does anybody know how to do this syntax below in mysql?
without Stored Procedure
and in single query only
SELECT CASE
WHEN COUNT(v.value) = 0 THEN (
INSERT INTO tbl_v (fid, uid, VALUE)
SELECT fid, 1 AS uid, 'xxxxxx' AS VALUE FROM tbl_f
WHERE category = 'categoryname' AND NAME = 'somevalue'
)WHEN v.value <> 'test' THEN (
'update syntax here' /* will be similar like insert statement above */
)ELSE (
v.value
)END
FROM shared_tbl_f f
INNER JOIN tbl_v v ON f.fid = v.fid
WHERE v.uid = 1 AND f.category = 'categoryname' AND f.name = 'somevalue'
note:
there's no primary key on tbl_v the unique reference for tbl_v is only a combination from column fid and column uid.
because tbl_v is a mapping table (there's no primary key there) - fid and uid is a foreign key from another table