根据另一个表中的存在,从表中选择

Guys I want to Select from table articles depending if code is in table called 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. Any help?

This is table inStock

enter image description here

And this is table articles

enter image description here

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

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

Please try the below query:

SELECT `A`.*, `S`.`price` 
FROM inStock S 
JOIN articles A 
ON (`S`.`code` = `A`.`code`);

Here you have a Demo for this: