MySQL Forums
Forum List  »  PHP

php script for join, using group by based on user input
Posted by: Rebecca Hudson
Date: December 01, 2022 02:31PM

I have been trying for a couple days to get my code to group by a StockCode and list all of the associated alternates. I get the listing and can use the variable inputs from users to pull up what is needed but visually it can be hard to look at since the stock code is listed repeatedly for each alternate part associated with the StockCode.

When I tried to perform a group by in workbench to test the script it gives me a 1055 error. Can someone help. My query code snippet is below.

$result = mysqli_query($con,"SELECT
qadb.cm_dbo_invmaster.StockCode, qadb.cm_dbo_invmaster.Description, qadb.cm_dbo_mfr_mfrpn.ManufacturerName, qadb.cm_dbo_mfr_mfrpn.ManPartNumber, qadb.cm_dbo_mfr_mfrpn.CageCode
FROM qadb.cm_dbo_invmaster INNER JOIN qadb.cm_dbo_mfr_mfrpn
ON qadb.cm_dbo_invmaster.StockCode = qadb.cm_dbo_mfr_mfrpn.StockCode
WHERE qadb.cm_dbo_invmaster.StockCode Like '".$NumberCriteria."'
AND qadb.cm_dbo_invmaster.Description Like '".$DescriptionCriteria."'
GROUP BY qadb.cm_dbo_invmaster.StockCode
ORDER BY qadb.cm_dbo_invmaster.StockCode");

The Query works until I put in the Group By Statement.

Options: ReplyQuote

Written By
php script for join, using group by based on user input
December 01, 2022 02:31PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.