I'm quite new to PHP and MySQL. I'm stuck with a problem, i will try to explain my problem.
TODAY = 2013-01-13 18:37:00
PRODUCT = P000001
TABEL : ASSEMBLY
-----------------------------------------------------------------
∣ PRODUCT ∣ COMPONENT ∣ BEINFORCE ∣ WILLEXPIRE ∣
-----------------------------------------------------------------
∣ P000001 ∣ C000001 ∣ 2013-01-01 18:37:00 ∣ 0000-00-00 00:00:00 ∣
-----------------------------------------------------------------
∣ P000001 ∣ C000002 ∣ 2013-02-01 18:37:00 ∣ 0000-00-00 00:00:00 ∣
-----------------------------------------------------------------
∣ P000001 ∣ C000003 ∣ 2013-01-01 18:37:00 ∣ 2013-01-10 18:37:00 ∣
-----------------------------------------------------------------
Output must be:
-----------------------------------------------------------------
∣ PRODUCT ∣ COMPONENT ∣ BEINFORCE ∣ WILLEXPIRE ∣
-----------------------------------------------------------------
∣ P000001 ∣ C000001 ∣ 2013-01-01 18:37:00 ∣ 0000-00-00 00:00:00 ∣
-----------------------------------------------------------------
Query from table ASSEMBLY must check PRODUCT, BEINFORCE and WILLEXPIRE and output table.
If I understand you correctly, including the comment below your question, then you want those rows of ASSEMBLY
which
BEINFORCE
less than or equal to TODAY
WILLEXPIRE
which is zero, which I take to denote a date in the futurePRODUCT
you requestedYou can achieve this using the following query, assuming user variables to represent your parameters. You could of course use prepared query placeholders as well.
SELECT *
FROM ASSEMBLY
WHERE BEINFORCE <= @TODAY
AND WILLEXPIRE = '0000-00-00 00:00:00'
AND PRODUCT = @PRODUCT