Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySql Issue -  Problem exporting subset of queried data

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
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 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
Course of the Month8 days, 22 hours left to enroll

876 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