Solved

MySQL SQL Syntax question exclude data

Posted on 2008-06-18
2
749 Views
Last Modified: 2013-12-12
I am using the following SQL query to pull matching data.  Some of the results may not have data for fields sLatitude and sLongitude.  How do I exclude these records when these fields are empty in my SQL query?
SELECT * FROM Residential, property_coordinates
        WHERE sSubdivision='Pines'
        AND Residential.sMLSNumber=property_coordinates.sMLSNumber

Open in new window

0
Comment
Question by:pda4me
2 Comments
 
LVL 22

Assisted Solution

by:dportas
dportas earned 50 total points
ID: 21812645
Assuming that "empty" means "null", do:

SELECT *
        FROM Residential, property_coordinates
        WHERE sSubdivision='Pines'
        AND Residential.sMLSNumber=property_coordinates.sMLSNumber
        AND sLatitude IS NOT NULL
        AND sLongitude IS NOT NULL ;
0
 
LVL 4

Accepted Solution

by:
albuitra earned 450 total points
ID: 21812660
Try with this
SELECT * FROM Residential, property_coordinates
        WHERE sSubdivision='Pines'
        AND Residential.sMLSNumber=property_coordinates.sMLSNumber
AND sLatitude is not NULL and sLatitude != '' 
and sLongitude is not NULL and sLongitude != ''

Open in new window

0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

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…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

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