Skip to content
Advertisement

SQL Query not displaying correctly

I am running a query and the result is not showing correctly, unfortunately, I am not sure what is the problem. Would anyone be kind enough to provide some assistance please?

Query;

SELECT a."Article_id"
    ,a."Article_topic"
    ,c."Comment_content"
FROM PUBLIC."Articles" a
INNER JOIN PUBLIC."Comments" c ON a."Article_id" = c."Article_id"
WHERE c."Comment_id" = 2;

Result:

Query Result

Advertisement

Answer

Your problem is that a field that you select is very big, that’s why it’s shown this way.

I’d bet on “Comment_content” having large values in it.

You can try something like :

SELECT a."Article_id"
    ,SUBSTRING(a."Article_topic", 0,50) as Article_topic_truncated
    ,SUBSTRING(c."Comment_content", 0,50) as Comment_content_truncated
FROM PUBLIC."Articles" a
INNER JOIN PUBLIC."Comments" c ON a."Article_id" = c."Article_id"
WHERE c."Comment_id" = 2;

Another way to fix that would be to show the results vertically. You do so by ending the query with G :

SELECT a."Article_id"
    ,a."Article_topic"
    ,c."Comment_content"
FROM PUBLIC."Articles" a
INNER JOIN PUBLIC."Comments" c ON a."Article_id" = c."Article_id"
WHERE c."Comment_id" = 2G
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement