I'm trying to make a query that links the name of the client that's on the client table to the cargo that has the corresponding id. I'm doing this query:
SELECT c.id, c.status, c.client_id, c.dt, c.cargo_date, c.cargo_hour, c.origin, c.destination, c.code_name, c.download_at, c.download_hour, c.weight, c.ramp_id, c.truck_id, c.driver_id, c.cargo_return, c.returning, c.description, cl.name, cl.id
from cargos c,
clients cl
where c.status = 'planner' and (c.destination != 'SANTIAGO')
or (c.destination = 'SANTIAGO' and c.returning is not NULL)
AND c.client_id = cl.id
order by COALESCE(c.returning, c.id);
but when I do that it returns me each cargo with every client in my client's table, isn't the AND c.client_id = cl.id supposed to make the result unique per id?
JOINsyntax.