by Adolfo » Tue Jun 23, 2015 11:57 am
Dutch.. you must be more specific..
1.- Are the tables 1 to 1.... 1 Record in ccrtbl and 1 record in ccrgst ?
2.- Are the tables master to child.... 1 Record in ccrtbl and many records in ccrgst ?
3.- How many fields are there in the 2 tables ?
4.- Both tables have an Index with the relation field ?
Answers to possible errors...
1.- Here is the most perfect relation... there must be no error and the query is very fast... if there is 1 to 1 relation
2.- Here you must thing backwards.... Select on the child table... the numbers of resulting rows must be the initial number of records in that table. So very fast indeed.... BUT. If you do it all the way around you may have a big resulting query, then a slow query result.
3.- If you have 50 fields on the tables, you must assume that you are going to get a 100 fields query. Then the idea is to reduce it to have only the required fields to work in the query. Also try to use alias.
Ex.
Select chi.code, chi.number, chi.ammount, mas.date, mas.client from child as chi left join master as mas on chi.CodeMas=mas.Code
4.- Best way of having fast and accurate results, the fields used to do the relation mus be and index too in both tables.
Hope it helps.
From Chile
Adolfo
;-) Ji,ji,ji... buena la cosa... "all you need is code"
http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650