Solved

MySql Issue -  Problem exporting subset of queried data

Posted on 2013-11-18
2
261 Views
Last Modified: 2013-11-24
I'm running MySql version 5.5.32-cll and trying to export subset of queried data but end up exporting the whole query

I'm running the following query:

SELECT q1.value,c.id,c.companyname,c.address1,c.address2,c.city,c.state,c.postcode,CONCAT(c.firstname , " " , c.lastname),c.phonenumber
FROM tblclients c LEFT OUTER JOIN
(SELECT cf.id,cfv.relid,cf.fieldname,cfv.value FROM tblcustomfields cf INNER JOIN tblcustomfieldsvalues cfv ON cf.id = cfv.fieldid WHERE cf.fieldname = "AccountCode") q1
ON c.id = q1.relid

Can somebody advise where i'm going wrong. Do i need to add any additional text to just export the subset?
0
Comment
Question by:Glyn Merritt
2 Comments
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
Comment Utility
I think you need to use INNER JOIN here:
SELECT q1.value,c.id,c.companyname,c.address1,c.address2,c.city,c.state,c.postcode,CONCAT(c.firstname , " " , c.lastname),c.phonenumber
FROM tblclients c INNER JOIN
(SELECT cf.id,cfv.relid,cf.fieldname,cfv.value FROM tblcustomfields cf INNER JOIN tblcustomfieldsvalues cfv ON cf.id = cfv.fieldid WHERE cf.fieldname = "AccountCode") q1
ON c.id = q1.relid

Open in new window

0
 
LVL 1

Author Closing Comment

by:Glyn Merritt
Comment Utility
Great work, thank you.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now