Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MySql Issue -  Problem exporting subset of queried data

Posted on 2013-11-18
2
Medium Priority
?
268 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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

688 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