-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Daniel Crookston wrote: | Does anyone know how to combine these two MySQL queries into one? | | create temporary table tmp_fs select * from fee_schedules where doctor_id=2; | | select description from procedures left join tmp_fs | on tmp_fs.procedure_id = procedures.id | where tmp_fs.id is null;
Wouldn't this work?
select description from procedures p left join fee_schedules fs ~ on fs.procedure_id=p.id and fs.doctor_id=2 ~ where fs.id is null;
~From what I understand, a LEFT JOIN will create the result set as if it were an INNER JOIN with the LEFT JOIN's ON clause as the WHERE clause, then add a row (supplemented with NULLs for the columns from the right hand side) for each record in the left hand side not yet appearing.
Limiting the doctor_id in the ON clause of the LEFT JOIN should have the same effect then as reducing the original table to a temporary table using a simple select.
Am I wrong?
Jacob Fugal -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFAAwm7/PO7QochUiQRAsdXAJ45Q/kxWyK2p/aYcwMU2Eyl5FsD0ACghsiP OM4rq5l5arNNRLeM+B6wW1Q= =GqJ3 -----END PGP SIGNATURE-----
____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
