How to get the data from two different tables? [duplicate]

-1

I'm having a problem, I'm doing a site where I get the images from two different tables, but I can only call one what I should do, can someone please help me?

    
asked by anonymous 24.08.2016 / 01:58

1 answer

0

You can do this as follows:

SELECT * FROM tabela1 as t1
LEFT JOIN tabela2 as t2 USING(id)

In this way, you get everything from the two tables, but you can also specify what you want to search for:

SELECT
   t1.imagem,
   t1.id,
   t2.imagem,
   t2.id
FROM tabela1 as t1
LEFT JOIN tabela2 as t2 USING(id)

In both cases, they would work fine. But it's a bit uncomfortable to come up with an exact answer, based only on texts, not specific information from your database.

    
24.08.2016 / 02:02