-1

Let's say I have these 2 tables:

ArticleTBL

+---------+----------+-------------+------------+
|articleid| typeid   | price       | user       |  
+---------+----------+-------------+------------+
|   0     |    2     |  1          | 122        |
|   1     |    3     |  2          | 344        |
|   2     |    3     |  1          | 455        |
|   3     |    1     |  4          | 34         |
+---------+----------+-------------+------------+

TypeTBL

+---------+----------+-------------+
|typeid   | type     | factory     |  
+---------+----------+-------------+
|   0     |  wooden  |  factry1    |
|   1     |  plastic |  factry2    |
|   2     |  metal   |  factry3    |
|   3     |  sth.    |  factry4    |
+---------+----------+-------------+

How do I request all this information only with articleid for each row?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jonas
  • 1
  • 2
  • 1
    You're looking for a "join". Here's some info: https://stackoverflow.com/questions/5706437/whats-the-difference-between-inner-join-left-join-right-join-and-full-join/28719292 – Cully Nov 05 '22 at 04:24
  • 1
    Please add the expected outcome. – Jonas Metzler Nov 05 '22 at 04:46
  • No, your answer doesn't make sense to me because the condition "WHERE article_id=0" was not intended - or at least the author didn't mention this. Furthermore, which outcome is exactly intended, should be explained by the author and then people can replicate whether your answer and/or another one satisfies that. – Jonas Metzler Nov 05 '22 at 13:54
  • a little, but like Jonas Metzler said, i think it only shows one row. I will check later if I can make it work with this solution. – Jonas Nov 05 '22 at 17:35
  • @JonasMetzler Comments discussing a specific answer belong in the comments section of that answer. – Cully Nov 05 '22 at 19:00

1 Answers1

0

Isn't this what you want? Read more

SELECT     a.articleid,
           a.price.a.USER,
           t.typeid,
           t.type,
           t.factory
FROM       form ArticleTBL a
INNER JOIN typetbl t
ON         a.typeid = t.typeid
WHERE      a.articleid = 0
Sachith Wickramaarachchi
  • 5,546
  • 6
  • 39
  • 68