First, sorry for my english because I'm french
I have two tables : "taches" and "taches_has_sites", and "taches_has_sites" have many of "taches" column but don't care about it, that's normal.
I'm working on a TODO list (list of task), and a task is for every sites. I have a button in all my sites pages for say "ok, I have do this task for this site" and to put the task in the table "taches_has_sites" with the idx_site (ID of the site) and a dt_exe (date of execution)
I need to do a SQL request for take task from the table "taches" :
that are not on the table "taches_has_sites"
or that are on the table "taches_has_sites" but with a "dt_exe" that is not on his "periodicity"
I'm doing this :
`SELECT t.idx_tache AS 'idx_tache',
t.dt_add AS 'dt_add',
t.dt_maj AS 'dt_maj',
t.dt_delete AS 'dt_delete',
t.titre AS 'titre',
t.description AS 'description',
t.priorite AS 'priorite',
t.periodicite AS 'periodicite'
FROM taches AS t LEFT JOIN taches_has_sites AS ths
ON t.idx_tache = ths.idx_tache
WHERE t.dt_delete IS NULL
AND ths.idx_site = #idx_site#
AND (t.periodicite LIKE 'unique' AND (dt_exe LIKE #date1#) //unique = ony one time
OR (t.periodicite LIKE 'jour' AND (dt_exe LIKE '%'#dateJ#'%')) //jour= day
OR (t.periodicite LIKE 'semaine' AND (dt_exe LIKE '%'#dateS#'%')) //semaine = week
OR (t.periodicite LIKE 'mois' AND (dt_exe LIKE '%'#dateM#'%')) //mois = month
OR (t.periodicite LIKE 'annee' AND (dt_exe LIKE '%'#dateA#'%')))`//annee = year
With :
$idx_site = The ID of the site
$date1 = "%";
$dateJ = date('Y-m-d');
$dateS = date('Y-W');
$dateM = date('Y-m');
$dateA = date('Y');
but it don't takes my tasks... help me plz