简体   繁体   中英

Select all items from a table and check if there is corresponding items in another table

i'm trying to workout this problem :
I got a table A of default value and a table B of custom value for certain entities.
For example :
I got my first table of default value here
在此处输入图片说明
And i want to select all of them , but i also want the one from the value table B 在此处输入图片说明


I can do that for every entry with a simple join, the problem is that i want only the value of the entity #45, So in the end it would look something like that :
在此处输入图片说明

If any ones has any idea on how to do this or at least some references it would be greatly appreciated.
Thanks and have a good day!

Use this

SELECT t1.*
 ,t2.value
FROM table1 t1
LEFT JOIN
TableB t2 
ON t1.id = t2.fk_id_setting
And t2.fk_id_entities=45

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM