Select only if the ID is in 2 tables [closed]

0

I have 2 tables in Mysql, INSCRICAO1 and INSCRICAO2 . Both have a field called COD that receives a user code.

A INSCRICAO1 saves the user's personal information INSCRICAO2 stores user's car information

I need to select only INSCRICAO1 from users who have cars, that is, they are also present in the INSCRICAO2 table.

How to do it, I tried with LEFT JOIN, but it gave an error.

    
asked by anonymous 03.04.2018 / 22:27

2 answers

1

Do this:

SELECT * FROM  inscricao1 INNER JOIN inscricao2 ON inscricao1.cod = inscricao2.cod
    
03.04.2018 / 23:33
0

I thought of a different way:

SELECT a.cod, b.cod FROM INSERT a1, INSERT a2 b WHERE a.cod = b.cod;

Simple like this using aliases.

    
04.04.2018 / 15:42