?
Solved

MySQL SQL Syntax question exclude data

Posted on 2008-06-18
2
Medium Priority
?
753 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
[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 22

Assisted Solution

by:dportas
dportas earned 200 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 1800 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

801 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