SQLite3 doesn't have concat_ws, looking for workaround
You can use CASE:

SELECT coalesce(col1, '')
       || CASE
            WHEN coalesce(col1, '') &lt;&gt; ''
                 AND (coalesce(col2, '') &lt;&gt; ''
                       OR coalesce(col3, '') &lt;&gt; '')
              THEN ' '
            ELSE
              ''
          END
       || coalesce(col2, '')
       || CASE
            WHEN coalesce(col2, '') &lt;&gt; ''
                 AND coalesce(col3, '') &lt;&gt; ''
              THEN ' '
            ELSE
              ''
          END
       || coalesce(col3, '')
       FROM elbat;