how to write the right query to get only needed fields (Nest, MySQL)


i have two tables: users and freelancer, which connected one to one. I’m trying to query data from freelancer table, and I also need one field from users table. But with code like this:

    .leftJoinAndSelect('freelancer.user', 'users')
    .where(`freelancer.userId = ${id}`)

I recive all data from users table. I tryed make it in diffirent ways with leftJoinAndMapOne but I have errors everytime. I can’t figure out how to write correctly. this is query what i’ve got, but I need something like this


Have you tried inner join if not then try it, and also you are using some dots instead of commas try them

for example you are doing this in your 2nd image that you have shared

SELECT freelancer.*, from freelancer left join users on;

instead you can try it like

SELECT,*,, from freelancer f inner join users u on;

try this and let me know i will update it accordingly

Answered By – ammad youasf

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published