Query with two tables

Asked

Viewed 36 times

0

I’m on a project, I have client table and work. A job has a client. I’ve already listed the tables, but I need to select that from the client id in the work table, return the client name.

I have to make a query to display in my php code.

Can someone please help me?

1 answer

2

Supposing your tables are like this:

CLIENT int id, client name VARCHAR

WORK id int id_client int descr_work VARCHAR

You could do it like this:

SELECT a.id, a.descr_trabalho, b.nome_cliente from TRABALHO a 
    left join CLIENTE b on
       a.id_cliente = b.id

Browser other questions tagged

You are not signed in. Login or sign up in order to post.