I tried to send the following query to a MSSQL Server using Doctrine in Symfony:
DECLARE @ebayitems TABLE (kartikel INT, cartnr VARCHAR(255), ebayPrice DECIMAL(10,2), ebayID VARCHAR(255))
DECLARE @amazonitems TABLE (kartikel INT, cartnr VARCHAR(255), amazonPrice DECIMAL(10,2), amazonPriceVersand DECIMAL(10,2), amazonASIN VARCHAR(255))
DECLARE @shopitems TABLE (kartikel INT, cartnr VARCHAR(255), ebayPrice DECIMAL(10,2), latestEbayID VARCHAR(255), amazonPrice DECIMAL(10,2), latestAmazonASIN VARCHAR(255))
INSERT INTO @ebayitems
select tArt.kartikel, tArt.cartnr, ebay.ebay_price AS ebayPrice, ebay.ItemID AS ebayID
...
GROUP BY tArt.kartikel, tArt.cartnr, ebay.ebay_price, ebay.ItemID
INSERT INTO @amazonitems
select tArt.kartikel, tArt.cartnr, amazon.fprice, CASE WHEN amazon.fprice < 315 THEN amazon.fprice + 4.90 ELSE amazon.fprice + 5.90 end AS amazonPrice, amazon.casin1 AS AmazonASIN
...
GROUP BY tArt.kartikel, tArt.cartnr, amazon.fprice, amazon.casin1
INSERT INTO @shopitems
SELECT ebayitems.kartikel, ebayitems.cartnr, ebayPrice, MAX(ebayID) AS latestEbayID, amazonitems.amazonPriceVersand, max(amazonitems.amazonASIN) AS latestAmazonASIN
...
GROUP BY ebayitems.kartikel, ebayitems.cartnr, ebayPrice, amazonitems.amazonPriceVersand
SELECT items.cartnr,
tPreis.kpreis AS kpreis,
(CASE WHEN ebayPrice > amazonPrice THEN (FLOOR(MIN(amazonPrice) * 0.95)-0.10) / 1.19
ELSE (FLOOR(MIN(ebayPrice) * 0.95)-0.10) / 1.19 END) AS shoppreis,
ebayprice,
latestEbayID,
amazonprice,
latestAmazonASIN
...
GROUP BY items.cartnr, kpreis, ebayprice,
latestEbayID,
amazonprice,
latestAmazonASIN
and I get the error from the title.
If I run the whole thing from HeidiSQL it works perfect but if I try the following code it won't (the $conn variable is correctly set, the connection is working)
$items = $conn->executeQuery($selectSQL);
var_dump($items->fetchAllAssociative());
Anyone has any idea about what should I do?