[英]Make Select from table depending of existence in another table
Guys I want to Select from table articles
depending if code
is in table called inStock
. 我想从表格articles
选择的人,具体取决于code
是否在名为inStock
表中。 So for example if I have in column code
in table inStock
224 I need to Select * FROM articles
having that code and for every item same. 因此,举例来说,如果我有在列code
表inStock
224我需要SELECT * FROM articles
具有代码和相同的每一个项目。 Any help? 有帮助吗?
This is table inStock
这是在inStock
中的表格
And this is table articles
这是表格articles
Try with the following query: with inner join you can get this as code need to present in both table, hopefully you'll get your desired ans 尝试使用以下查询:使用内部联接,您可以获得此代码,因为代码需要在两个表中显示,希望您将获得所需的ans
select a.id,a.code,a.name,a.description,a.amount,a.color,b.price
from articles a inner join instock b
on a.code=b.code
SELECT articles.*, inStock.Price
FROM articles INNER JOIN inStock ON articles.code = inStock.code
INNER JOIN will return the records that are present in both the tables based on the columns that you are joining INNER JOIN将根据您要加入的列返回两个表中存在的记录
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.