-1

I have a two tables in MySQL. I want to create a SELECT that will work in the following way:

Select from the table s_articles_supplier those lines whose id is equal to the active = 1

s_articles_supplier:

id   | name
100  | Nike
101  | Adidas

s_articles:

supplierID | active
100        | 1
101        | 0
  • 4
    Have you tried a query yet? If we just spoon feed you the answer, you won't learn very much :-| – Tim Biegeleisen Oct 04 '18 at 07:31
  • 5
    Possible duplicate of [SQL: Select from one table matching criteria in another?](https://stackoverflow.com/questions/5446778/sql-select-from-one-table-matching-criteria-in-another) – Kaddath Oct 04 '18 at 07:31

2 Answers2

0

Use simple join with where condition

select a.id, name from s_articles_supplier a
inner join s_articles b on a.id=b.id
where active=1
Fahmi
  • 37,315
  • 5
  • 22
  • 31
0

You have to use inner join in following way for expected result

SELECT id, name FROM s_articles_supplier
INNER JOIN s_articles ON s_articles_supplier.id=s_articles.supplierID
WHERE s_articles.active=1

Hope it helps you