how would one achieve the ability to select multiple columns that are similar in the statement below? I'm using the DISTINCT MySQL for the body, which works fine... but I cannot obtain additional information (columns) that goes with it. Any ideas would be appreciated, please let me know if you need more information from me.
SELECT DISTINCT T.body
FROM Posts T
LEFT JOIN Posts T2 ON T.body != T2.body
WHERE T.body LIKE CONCAT('%', T2.body, '%')
UNION
SELECT DISTINCT T2.body
FROM Posts T
LEFT JOIN Posts T2 ON T.body != T2.body
WHERE T.body LIKE CONCAT('%', T2.body, '%')
ORDER BY body;
Try adding column that you want to select. for example
SELECT DISTINCT T.body, T.Column1, T.Column2 FROM Posts T LEFT JOIN Posts T2 ON T.body != T2.body WHERE T.body LIKE CONCAT('%', T2.body, '%') UNION SELECT DISTINCT T2.body FROM Posts T LEFT JOIN Posts T2 ON T.body != T2.body WHERE T.body LIKE CONCAT('%', T2.body, '%') ORDER BY body;"