I have a slight problem that I have been racking my head over for a couple of days now.
I have a table (tblSubmissions) that holds a key, this key is attached to another table (tblListings) that could have up to 12 entries with the key from tblSubmissions. Inside the tblListings there is a field that denotes the end date (EndDate) of the row.
I am trying to get a MySQL query that will return a list of submissions that have all the end dates filled in with an actual date. What I actually get is a list of all submissions that don't have a '0000-00-00' in the date. The DISTINCT helps to only produce one submission, but that submission usually has more than one listing attached to it and one will generally have an end date of '0000-00-00'.
I various other criteria that must be met as well but that is where I am struggling.
Here is the code
$query = "SELECT DISTINCT SBX.SubmissionID, SBX.StoreID, SBX.SubxTitle, DATE_FORMAT(SBX.DateReceived, '%m/%d/%Y') AS DateReceived ";
$query .= "FROM tblSubmissions SBX, tblListings AUC ";
$query .= $wherestore.$wheredates."AND SBX.SubmissionID=AUC.SubmissionID AND SBX.CreatedBy Is NOT NULL AND SBX.SubmittedBy Is NOT NULL AND SBX.ApprovedBy Is NOT NULL AND SBX.RTSReason='' AND AUC.DateEnded != '0000-00-00' ";
$query .= "ORDER BY SBX.SubmissionID DESC";
$listTitle="Submissions Without Active Auctions";