Solved

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

Posted on 2010-09-07
2
264 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 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