1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Compare tables and show rows

Discussion in 'MySQL' started by piropeator, May 14, 2016.

  1. #1
    Hi. I have two tables:
    Table1 (COD, NOM)
    =====
    100 AA
    200 BB
    300 CC
    400 DD

    Table2: (COD, NOM)
    =====
    200 BB
    350 FF
    400 DDE
    500 HH

    I want this result from Table2
    COD NOM1 NOM2
    200 BB BB
    350 FF
    400 DD DDE
    500 HH

    Somebody can help me?
     
    Solved! View solution.
    piropeator, May 14, 2016 IP
  2. #2
    It's a good idea with these kinds of queries to set up a sql fiddle so that people can quickly write and test their suggestions.

    Here's mine: http://sqlfiddle.com/#!9/8620b/5
     
    sarahk, May 16, 2016 IP
  3. piropeator

    piropeator Well-Known Member

    Messages:
    194
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    121
    #3
    I found this:
    SELECT * FROM tabla2 LEFT OUTER JOIN tabla1 ON tabla1.codigo=tabla2.codigo
    
    PHP:
    I have the same result.
     
    piropeator, May 17, 2016 IP