I need some advice on how to create a SQL statement for a particular case in my data. I have two tables with the following areas:
horse_shows table horse_shows.showID horse_shows.horse_show_date horse_shows.horse_show_managerID horse_shows.horse_show_secretaryID - this field empty show_managers table to be show_managers.managerID show_managers.name show_managers Is allowed . Mail
Gode_so__morgraidi and Gode_so_ssiaidiaidi and Hors_so_sseediaiaidi Gode_sops table a Mandkaidi both show_managers table shows the map. Therefore horse_show_secretaryID field in the horse_shows table can not be empty, all of the show will be a show secretary.
I just together on the show for a show, want to print show manager, and show secretary unique ID and if horse_show_secretaryID field is blank Gode_sosh table, so I want her secretary would Low raid So I tried to do this:
SELECT horse_short: hosse_show_date, show_managers.name, show_secretaries.name horse_show Honda_Shows on Show_managers Horsse_show_managerID = show_managers.managerID show_managers show_searcharies as horse_shows.horse_show_secretaryID = on show_secretaries ManagerID where horse_shows.showID = 'XYZ';
However, the line of the show with the above statement showID returns if it finds a match on both horse_show_managerID and horse_show_secretaryID in show_managers table. If horse_show_secretaryID field is blank Gode_sosh table (which is a valid condition), statement gives no line I want to make it on to the 'XYZ' show manager (and a spare) Secretary return when horse_show_secretaryID blank area is.
Can anyone help me?
Thank you! Using
include
on your own using a Will join the interiors
which means that the inserted condition should be completed. Use LEFT JOIN
instead of:
horse_shows.horse_show_date, show_managers.name, horse_shows.horse_show_managerID = on show_secretaries.name Left show_managers from horse_shows show_managers .managerID Left Show_managers Join Join Horse as show_security; Hosse_show_secretaryID = show_secretaries.managerID where horse_social.SoID = 'XYZ';
Comments
Post a Comment