• For statistical purposes I want to retrieve the comments that have the longest length. MySQL doesn’t like this standard query:
    select *
    from wp_comments
    where length(comment_content) =
    (select max(length(comment_content)) from wp_comments);

    How come? I know how to do it using more than one query, but I’d like to be able to pull the information in one go.
    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • SELECT MAX(comment_content) FROM wp_comments;
    Next time try the manual
    Regards, MaxT

    Thread Starter jcairns

    (@jcairns)

    That doesn’t do what I asked.
    I want to return all the fields for the comments (there could be more than one) that have the longest length. Your query merely returns the comment’s content that has the maximum length.

    Try to read what you wrote:

    For statistical purposes I want to retrieve the comments that have the longest length

    See that? That can be misunderstanded… Next time try to make it more narrow /exact what is it you are looking for…
    And for the record

    I want to return all the fields for the comments (there could be more than one) that have the longest length.

    In english word “longest” means the one that have the greatest value of all possible… And there can be only 1 longest comment…
    Try to restate what you want…

    I didn’t read your sql at all in the first run as you said it didn’t worked…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Retrieving comment with longest length’ is closed to new replies.