简体   繁体   中英

MySQL query to select multiple users

SELECT * FROM users LEFT JOIN (company_users) ON users.user_id=company_users.C_C_OWNER WHERE company_users.C_C_OWNER='19' 

I get the following: 在此处输入图片说明

What I need to do is use the C_USER_ID field to select users in the user_id field under the users table. So far every way I try I get blank results. For example, there is a user 22 I want to grab.

SELECT * 
FROM users LEFT JOIN (company_users) 
ON users.user_id=company_users.C_USER_ID 
WHERE company_users.C_C_OWNER='19' 

Guess my coffee did not kick in yet. I just needed to change where my select query was pointing.

SELECT * FROM users ,company_users
WHERE users.user_id=company_users.C_C_OWNER 
AND company_users.C_C_USER_ID='22' 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM