?
Solved

Display query results even if I can't match 2 columns from 2 different tables

Posted on 2010-09-07
2
Medium Priority
?
268 Views
Last Modified: 2013-12-13
Here is my query

SELECT hlp_hed_key, hlp_chan_num, hlp_callsign, FullName FROM gn_stage.stg_stations, gn_config.cfg_headend_lineup WHERE hlp_callsign=Call_Sign AND hlp_hed_key='$h' ORDER BY hlp_chan_num + 0 ASC

Open in new window


I display the results of this query in my webpage.  The problem is that if hlp_callsign does not match a field in Call_Sign then the row doesn't display at all.  I would like to display all of the other data and perhaps show hlp_callsign in red indicating it is bad and needs edited.

Thanks for the help on this.
0
Comment
Question by:kevandju
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 2000 total points
ID: 33621739
SELECT hlp_hed_key, hlp_chan_num, hlp_callsign, FullName
FROM gn_config.cfg_headend_lineup left join gn_stage.stg_stations
 ON hlp_callsign=Call_Sign
WHERE hlp_hed_key='$h'
ORDER BY hlp_chan_num + 0 ASC


It would be a good idea to alias the table names... and to indicate where each column comes from.
When the join doesn't match, hlp_callsign will be NULL, which you can check for in PHP and use to color the row/cell red.
0
 

Author Comment

by:kevandju
ID: 33621857
Thank you that worked perfectly and I understand what you mean about the Aliases.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question