0

How can I compare two fields from two tables with IN clausule, but, one of the fields has one one "value" and the other field I have a group of values?

TABLE_FOO:
FOO (int)
1
2

TABLE_BAR:
BAR     FOO (string)
1       1,2

Thats my SELECT:

SELECT * FROM TABLE_FOO, TABLE_BAR WHERE TABLE_FOO.FOO IN TABLE_BAR.FOO

I can't get the result of this query.

EDIT I think that its not a duplicated question, as my problem here is to "Link" two tables through relational (joins) 'select'.

Killer
  • 188
  • 3
  • 14
  • 2
    The real solution is to change your table design. Never store multiple values in a single column! – juergen d Aug 31 '17 at 23:05
  • Its not "my" table design. If it was, I never would do that. Unfortunable, that is how "they" are doing it. Sorry – Killer Aug 31 '17 at 23:15
  • 1
    @Killer - the JOIN condition is similar to a WHERE condition. The incorrect answer posted by Jon Ekiz is just his misunderstanding of the correct one, from the linked question. Read the answer there and you will be able to fix your JOIN. –  Aug 31 '17 at 23:42
  • I will try @mathguy – Killer Aug 31 '17 at 23:43

0 Answers0