I have two MySQL tables something like this:
tool_owners:
tool_owners_id | user_id | ...
tools:
tools_id | tool_owners_id | tool_name | ...
I have the user_id and tool name. I need to check to see if the user
owns a specific tool. The challenge is that these bits of information (the user_id and tool_name) are in separate tables, where the rows are linked by tool_owners_id.
In case anyone is wondering, I can't change the structure of the tables.
Is what I'm asking possible? The only way I know how to do this is to make a first query getting the tool_owners_id from the tool_owners table, then a second query doing COUNT(*) where the tool_owners_id = xxx AND tool_name = xxxx from the tools table.
Thanks for your help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…