本文介绍了MySql Inner Join with WHERE子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
SELECT table1.f_id FROM table1 WHERE table1.f_com_id = '430' AND
table1.f_status = 'Submitted'
INNER JOIN table2
ON table2.f_id = table1.f_id
where table2.f_type = 'InProcess'
我需要来自table1
的信息,因为与f_com_id
关联的所有id都为430,状态为已提交,并且该类型仅在存储在其他表(table2
)中的状态中
I need information from table1
as all the id associated with f_com_id
as 430 and status as submitted and the type should be only in process which is stored in other table(table2
)
f_id
分别是p_key
和f_key
.
但这给了我错误,我想我把WHERE
子句放错了,如何解决.
f_id
is p_key
and f_key
in both the tables.
But this giving me errors, I think I am placing the WHERE
clause wrong, how to fix it.?
推荐答案
是的,您是对的.您将WHERE
子句放置错了.您只能在单个查询中使用一个WHERE
子句,因此对于以下多个条件请尝试AND
:
Yes you are right. You have placed WHERE
clause wrong. You can only use one WHERE
clause in single query so try AND
for multiple conditions like this:
SELECT table1.f_id FROM table1
INNER JOIN table2
ON table2.f_id = table1.f_id
WHERE table2.f_type = 'InProcess'
AND f_com_id = '430'
AND f_status = 'Submitted'
这篇关于MySql Inner Join with WHERE子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!