Lightwalker
asked on
MySQL query results as comma separated
Dear Experts,
I have a frustrating problem that I thought would be simple but I am not finding the solution.
I have a Query below:
SELECT orderdetails.DetailsID FROM orderdetails WHERE orderdetails.ProgramActiva ted = 2
this would give me results such as:
DetailsID:
513
516
As you can see the results are in a list, where as what I want to do is have the results separated by a comma (,) to be used in another SQL query.
So the above results should be:
DetailsID
513, 516
I have been reading about GROUP_CONCAT which I was hoping would do it but I am not able to get it to work for me as the result is simply [BLOB] from the query below:
SELECT GROUP_CONCAT(orderdetails. DetailsID) AS DetailsID FROM orderdetails WHERE orderdetails.ProgramActiva ted = 2
Any suggestions?
Many thanks as always for your help.
I have a frustrating problem that I thought would be simple but I am not finding the solution.
I have a Query below:
SELECT orderdetails.DetailsID FROM orderdetails WHERE orderdetails.ProgramActiva
this would give me results such as:
DetailsID:
513
516
As you can see the results are in a list, where as what I want to do is have the results separated by a comma (,) to be used in another SQL query.
So the above results should be:
DetailsID
513, 516
I have been reading about GROUP_CONCAT which I was hoping would do it but I am not able to get it to work for me as the result is simply [BLOB] from the query below:
SELECT GROUP_CONCAT(orderdetails.
Any suggestions?
Many thanks as always for your help.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Dear stilliard,
you are a star. No I was not using phpmyadmin but I am using navicat for mysql as I tested the query.
As you mention about phpmyadmin I realized that I had not tested it inside my PHP script. When I did it shows up perfectly as comma seperated. So it is just in the navicat query editor it is showing up as blob.
Thank you for your insight.
you are a star. No I was not using phpmyadmin but I am using navicat for mysql as I tested the query.
As you mention about phpmyadmin I realized that I had not tested it inside my PHP script. When I did it shows up perfectly as comma seperated. So it is just in the navicat query editor it is showing up as blob.
Thank you for your insight.
Open in new window