dedicqted to yann
authorx2000habouzit <x2000habouzit>
Tue, 2 Nov 2004 14:13:13 +0000 (14:13 +0000)
committerx2000habouzit <x2000habouzit>
Tue, 2 Nov 2004 14:13:13 +0000 (14:13 +0000)
how to take the line in MySQL thqt minimize a constraint

scripts/cron/send_nl.php

index 79d32e6..b30cdce 100755 (executable)
@@ -19,7 +19,7 @@
  *  Foundation, Inc.,                                                      *
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************
-        $Id: send_nl.php,v 1.5 2004-11-02 11:34:17 x2000habouzit Exp $
+        $Id: send_nl.php,v 1.6 2004-11-02 14:13:13 x2000habouzit Exp $
  ***************************************************************************/
 
 require('./connect.db.inc.php');
@@ -50,8 +50,10 @@ while(true) {
     $sql = mysql_query("SELECT  ni.user_id,ni.pref, a.alias, u.prenom,u.nom, FIND_IN_SET(u.flags, 'femme')
                          FROM  newsletter_ins AS ni
                    INNER JOIN  auth_user_md5  AS u  USING(user_id)
-                   INNER JOIN  aliases        AS a  ON(u.user_id=a.id AND a.type='a_vie')
-                        WHERE  ni.last<$id
+                   INNER JOIN  aliases        AS a  ON(u.user_id=a.id AND a.type!='homonyme')
+                   LEFT  JOIN  aliases        AS b  ON(u.user_id=b.id AND a.type!='homonyme'
+                                                       AND LENGTH(a.alias)>LENGTH(b.alias))
+                        WHERE  b.alias IS NULL AND ni.last<$id 
                         LIMIT  60");
     if(!mysql_num_rows($sql)) exit(0);
     $sent = Array();