Skip to content
Advertisement

How to get values from phpmyadmin with the same datetime?

I am building a mini-portal/website and I need to select values with the same DateTime.enter image description here

For example, the first three values have the same DateTime and I would like to select them, yet I don’t know how the SQL code should look like.

Advertisement

Answer

This selects those records which has the same date attribute and orders them by the date attribute.

SELECT
    T2.*
FROM
    (
    SELECT 
       date
    FROM
       TABLENAME
    GROUP BY
       date
    HAVING
       COUNT(date) >= 2
    ) T1
    JOIN
    TABLENAME T2 ON T1.date = T2.date
ORDER BY date
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement