Advertisement

TrimwebsolutionsTrimwebsolutions

Problem and Solutions

Is there way to return null valued rows when when querying joined table in SQL ?

By M.K. Verma · 4 May 2022

Is there way to return null valued rows when when querying joined table in SQL ?

Try to use a nested SELECT, this should return null for the users without any event:

select 
    u.name, 
    SELECT(
      group_concat(content)  
        FROM 
      events 
        WHERE 
      userId = u.id
    ) as events 
from 
    users u
order by 
    u.id