-3
select patient_id from patient where date(visit.date_started) > date(patient.date_created)

The statement i think is self explanatory to what i am trying to do. I have two tables, patient and visit. I want to get patients who have started a visit, which is recorded on another table, on a later day than when the patient was registered in the system, which a patient is recorded when registered. note: All i need returned is the data on the patients table after the filter.

waweru
  • 1,024
  • 14
  • 16
  • 1
    Please refer to this link for some hints about how to build your query: [INNER JOIN ON vs WHERE clause](http://stackoverflow.com/questions/1018822/inner-join-on-vs-where-clause) – Sebas Oct 31 '14 at 19:21
  • what is the relation between "patient" and "visit" tables? – mwafi Oct 31 '14 at 19:33

1 Answers1

1

try this:

select patient.id
from patient,visit 
where date(visit.date_started) > date (patient.date_created)
mwafi
  • 3,946
  • 8
  • 56
  • 83
  • Thank you. this solution works well but it combines both tables into one table than returning only data from the first table – waweru Oct 31 '14 at 19:31
  • it return only what you select, in this case you select "patient.id" – mwafi Oct 31 '14 at 19:32