shoulders / qwcrm

QWcrm – Free and Open Source CRM Software.
https://quantumwarp.com/
GNU General Public License v3.0
38 stars 12 forks source link

Mysql join statements - wrong way around #1220

Open shoulders opened 5 years ago

shoulders commented 5 years ago

although this does not make any difference to the functionality it would be better if these were changed and would make the code easier to read.

see how the workorders is primary. This is taken from display_workorders()

verify this is how it should be done. Have I got them the right way around, ie should workorder be primary?

Bad

LEFT JOIN ".PRFX."user_records ON ".PRFX."user_records.user_id = ".PRFX."workorder_records.employee_id
LEFT JOIN ".PRFX."client_records ON ".PRFX."client_records.client_id = ".PRFX."workorder_records.client_id

Bad

LEFT JOIN ".PRFX."user_records
    ON ".PRFX."user_records.user_id = ".PRFX."workorder_records.employee_id
LEFT JOIN ".PRFX."client_records
    ON ".PRFX."client_records.client_id = ".PRFX."workorder_records.client_id

Good

LEFT JOIN ".PRFX."user_records ON ".PRFX."workorder_records.employee_id = ".PRFX."user_records.user_id
LEFT JOIN ".PRFX."client_records ON ".PRFX."workorder_records.client_id = ".PRFX."client_records.client_id  

Good

LEFT JOIN ".PRFX."user_records
    ON ".PRFX."workorder_records.employee_id = ".PRFX."user_records.user_id
LEFT JOIN ".PRFX."client_records
    ON ".PRFX."workorder_records.client_id = ".PRFX."client_records.client_id  
shoulders commented 5 years ago

might be useful