Mysql
 sql >> Database >  >> RDS >> Mysql

come visualizzare il record corrispondente dall'accesso basato su un'altra colonna in Datagrid in vb6

Puoi utilizzare una query in questo modo:

SELECT subjectcode.Year1, subjectcode.Year2, 
       subjectcode.Subjectcode, subjectcode.Subjectname, 
       subjectcode.Theory_Practical, q.fee
FROM subjectcode 
INNER JOIN (
       SELECT fees.Year1, fees.Year2, "Theory" As FeeType, 
              fees.Theoryfee As Fee
       FROM fees
       UNION ALL
       SELECT fees.Year1, fees.Year2, "Practical" As FeeType, 
              fees.Practicalfee As Fee
       FROM fees)  AS q 
ON (subjectcode.Theory_Practical = q.FeeType) 
   AND (subjectcode.Year2 = q.Year2) 
   AND (subjectcode.Year1 = q.Year1)

Tuttavia, faresti molto meglio a riprogettare la tabella delle tariffe in modo che corrisponda ai dati restituiti dallo sql interno, ovvero una linea diversa per le tariffe teoriche e pratiche:

Year1   Year2   FeeType     Fee
2001    2003    Theory      440
2001    2003    Practical   320