Hi SQLers,
I am searching for an SQL command to combine several many-to-many queries.
At the end I only want to get results suitable for all restrictions.
Better show you my tables:
USER
id name
1 frank
ROLE
id name
1 admin
2 general
GROUP
id name
1 groupA
2 groupB
USER_ROLE
Rapthor,
Try ...
SELECT u.name
FROM user u
JOIN user_role ur ON u.id=ur.user_id AND (u.id=1 OR u.id=2)
JOIN user_group ug ON u.id=ug.user_id AND (u.id=1 OR u.id=2)
HAVING COUNT( DISTINCT ur.role_id ) = 2
AND COUNT( DISTINCT ug.group_id ) = 2;
BTW you can't name a table 'group'; it's a
Great! With a little adaption it works! Yes and of course I have to use
another name for groups :) It was just an example. I have slightly different
table settings.
SELECT u.name
FROM user u
JOIN user_role ur ON u.id=ur.user_id AND (ur.role_id=1 OR ur.role_id=2)
JOIN user_group ug ON
Hello,
I have the following stored procedure
PROCEDURE `IsProductInForeignDatabase`(IN stock INTEGER(11), OUT MyResult
VARCHAR(1000), IN Behaviour VARCHAR(20))
The procedure above returns the MyResult out parameter.
I have a stored function as well thas has the body:
Begin
Declare MyResult
Hello.
I have a question about the behavior of SELECT ... LIKE and dealing with
the Korean language. For those who don't know anything about the way the
language's characters are formulated, I'll give you a quick crash course:
Korean has its own alphabet, just like Japanese, Chinese and most
Hi,
Is it possible to restrict Inserts and Updates to meet certain
conditions?
In one of my tables lets say field A, B and C can be NULL, but not
all at once. Depending on what type of item I want to store, A needs
to be NULL, but B and C need values, for other types A needs a value
but