We read your photo as:

Write a SQL query to find the names and surnames of all doctors who prescribed the medication with CodeSS: MEBENDAZOL224.

Computer Science

ScanSolve AI Answer

Step-by-step solution

4 steps
  1. Identify the tables needed.

    To find doctors who prescribed a specific medication, we need information from the DOCTOR, CONSULTATION, and PRESCRIPTION tables. The PRESCRIPTION table links CONSULTATION (and thus DOCTOR) to MEDICATION via CodeSS.

  2. Join the tables.

    We will join DOCTOR with CONSULTATION using Matricle, and CONSULTATION with PRESCRIPTION using ConsulNo.

  3. Filter by medication CodeSS.

    We will filter the results where CodeSS in the PRESCRIPTION table matches 'MEBENDAZOL224'.

  4. Select distinct doctor names.

    To avoid listing the same doctor multiple times if they prescribed the medication more than once, we use DISTINCT.

    1. The SQL query to list all the doctors who prescribed the medication with codeSS: MEBENDAZOL224 is:
    SELECT DISTINCT D.Name, D.Surname
    FROM DOCTOR D
    JOIN CONSULTATION C ON D.Matricle = C.Matricle
    JOIN PRESCRIPTION P ON C.ConsulNo = P.ConsulNo
    WHERE P.CodeSS = 'MEBENDAZOL224';
    
Was this helpful?

Still stuck on this one?

Ask a follow-up, and the answer starts from this question.

Got a different question?Ask your own question