Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

756 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