Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1957

Advanced Join (1 reply)

$
0
0
This is probably not a newbie question, but I really don't know where to post it.

What I'm trying to achieve is to join tables A and B on A.foo = B.foo and get a third table based on A with NULL or 0 from B for anything that didn't exist

Example tables:

Table A
foo    bar
  1    100
  2    100
  3    100
  4    100

Table B
foo    beer
  1    200
  3    200
  6    200
 79    200

and obtain this:

Joined Table
A.foo  A.bar  B.beer
    1    100    200
    2    100      0
    3    100    200
    4    100      0

Is this even possible?

Viewing all articles
Browse latest Browse all 1957

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>