i want to assign roles to users..
i have three tables users ( username, password, userid)
and groups( groupid, rolename)
role( groupid ,userid)
iss the sql query like this
SELECT COUNT(*)into v_count from roles WHERE groupid = 3 and userid=3;
IF v_count = 0
THEN INSERT INTO roles( groupid, userid) VALUES (3,4);
The Query i tried earlier is this.. which is wrong
query should be just like this.
help me to correct the syntax of that query.
if the userid and groupid are already in role.. it will select them otherwise it will insert them.
select roles.userid, roles.groupid from roles where users.username=chirstian and groups.rolename=admin
else insert userid and groupid in role where users.username=chirstian and groups.rolename=admin