Solved

MySql Issue -  Problem exporting subset of queried data

Posted on 2013-11-18
2
267 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
[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 25

Accepted Solution

by:
chaau earned 500 total points
ID: 39658155
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
ID: 39673141
Great work, thank you.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 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