Select some data from different tables

0

Rebuilding the programmer here, I'm having trouble with SQL and I'm asking for help.

I have two tables called orcamentos and clientes .

I need to select all fields from the orcamentos table and only the nome field from the clientes table when the orcamentos.id_cliente = clientes.id condition.

I have used so far as follows:

SELECT * FROM orcamentos tab1
INNER JOIN clientes tab2 ON (tab1.id_cliente = tab2.id)

It works, but returns all fields of the client table ...

    
asked by anonymous 05.04.2017 / 13:37

1 answer

2

Just specify the fields you want:

SELECT tab1.*, tab2.nome FROM orcamentos tab1
INNER JOIN clientes tab2 ON (tab1.id_cliente = tab2.id)

SELECT (Transact-SQL) Examples

    
05.04.2017 / 13:41