"NOT IN" question

A place to discuss MySQL issues.

"NOT IN" question

Postby Martin Pruss » Thu Aug 06, 2009 1:23 am

Hello Sql Experts

With the following query I am trying to get records from the week exactly one year ago to send them a remider to upgrade a product.
This works fine. Now I have to limit this query to the records which do not have a younger (<365) record with the same username/firstaname .
when I try this wth a "NOT IN" term, I can query only one operand (either name or first name) but I have to compare them in combination because the table is not perfectly normalized
Code: Select all
SELECT A.id, A.datum, A.kundenname, A.vorname, A.email, B.email AS partnermail
FROM table_one AS A
INNER JOIN users AS B ON B.UserName = A.owner
WHERE TO_DAYS( NOW( ) ) - TO_DAYS( datum ) >=365
AND TO_DAYS( NOW( ) ) - TO_DAYS( datum ) <=372
AND A.kundenname NOT
IN (

SELECT kundenname
FROM table_one
WHERE TO_DAYS( NOW( ) ) - TO_DAYS( datum ) <365
)


Any Ideas are welcome
Cheers
Martin
Martin Pruss
 
Posts: 53
Joined: Tue Oct 23, 2007 2:22 pm
Location: Berlin

Postby Martin Pruss » Thu Aug 13, 2009 1:02 pm

too easy?...
or too difficult?
Martin Pruss
 
Posts: 53
Joined: Tue Oct 23, 2007 2:22 pm
Location: Berlin


Return to MySQL Support

Who is online

Users browsing this forum: MSN [Bot] and 1 guest

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved