Solved

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

Posted on 2010-09-07
2
263 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
2 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
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…

773 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