* Admin-Stress
> I have a table called TRANSACTION, it has some fields :
>
> REGDATE - date of the transaction
> WHAT - a string (NOT UNIQUE)
> CUSTOMER - customer code
>
> I want to query all WHAT that the date of the transaction was 15
> days before.
>
> So, my sql query is :
>
> SELECT WHAT FROM TRANSACTION WHERE REGDATE < Now() -INTERVAL 15 DAY
>
> But, because of WHAT is not unique, then I could receive some
> duplicates (customer can send some WHAT in the same REGDATE).
>
> How can I query only the unique WHAT ? I need to list all WHAT
> (uniquely) that the date transaction was 15 days before.

Looks like you need the DISTINCT keyword:

<URL: http://www.mysql.com/doc/en/Selecting_columns.html#IDX391 >

SELECT DISTINCT WHAT FROM TRANSACTION WHERE REGDATE < Now() -INTERVAL 15 DAY

--
Roger


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to