首先,使用正确的 ANSI 连接语法:
SELECT distinct usr.user_id
FROM OCN.users AS usr
inner join OCN.users_groups_subscribe AS usr_grp on usr_grp.subscribe_user_id = usr.user_id
inner join OCN.tests_users AS test_usr on test_usr.test_user_user_id = usr.user_id
WHERE
test_usr.test_user_test_id=116 AND
(usr.user_first_name LIKE '%ajay%' OR usr.user_last_name LIKE '%ajay%')
ORDER BY usr.user_first_name, usr.user_last_name
现在尝试一一评论您的联接(连同相应的列),看看为什么您没有得到任何行,例如
SELECT distinct usr.user_id
FROM OCN.users AS usr
--inner join OCN.users_groups_subscribe AS usr_grp on usr_grp.subscribe_user_id = usr.user_id
inner join OCN.tests_users AS test_usr on test_usr.test_user_user_id = usr.user_id
WHERE
test_usr.test_user_test_id=116 AND
(usr.user_first_name LIKE '%ajay%' OR usr.user_last_name LIKE '%ajay%')
ORDER BY usr.user_first_name, usr.user_last_name