I claim ignorance of Friday morning...
I have three tables like so.
Table1
pid: primary key
product: one of a list of names (prod1, prod2, prod3)
filename: free text
Table2
sid: primary key
stage: one of a list of stages (ib, cr, pr)
Table3
pid: foreign key
sid: foreign key
timestamp:
Now, I want to grab all the products which are currently in a certain state. Say all the prod1's in cr, and I'm just being an idiot trying to make this query. I can of course easily get all the products that were -ever- in a certain state.
But, I want to also say, MAX(table3.timestamp) somewhere, ugh, this isn't hard, but like I said it's early friday
Thanks for any guidance.
I have three tables like so.
Table1
pid: primary key
product: one of a list of names (prod1, prod2, prod3)
filename: free text
Table2
sid: primary key
stage: one of a list of stages (ib, cr, pr)
Table3
pid: foreign key
sid: foreign key
timestamp:
Now, I want to grab all the products which are currently in a certain state. Say all the prod1's in cr, and I'm just being an idiot trying to make this query. I can of course easily get all the products that were -ever- in a certain state.
Code:
SELECT table1.pid, table1.name
FROM table1, table2, table3
WHERE table1.pid = table3.pid
AND table2.sid = table3.sid
AND table2.stage = 'cr'
But, I want to also say, MAX(table3.timestamp) somewhere, ugh, this isn't hard, but like I said it's early friday
Thanks for any guidance.