Hallo,
habe folgende Tabelle und möchte gerne alle Datensätze gruppiert nach Location und Produkten haben, welche zuletzt bearbeitet worden sind in einem bestimmten Jahr.
Wenn ich diese Abfrage nun mit MySQL 5.5.46 (Installiert auf Server) oder 5.5.32 (Laptop mit Xampp 1.8.2) durchführe, so kommt es zu keinem Ergebnis (es wird nur geladen und geladen....).
Führe ich die Abfrage nun mit meinem Rechner aus, auf welchem Xampp 7.0.3 mit 10.1.10-MariaDB installiert ist, so ist das Ergebnis nach 0.03sek da.
Mit der Abfrage müsste MySQL eigentlich gut zurecht kommen. Weiß jemand rat?
Tabelle:
CREATE TABLE `material_account` (
`ma_id` int(11) NOT NULL,
`ma_produkt_id` int(11) NOT NULL,
`ma_location_id` int(11) NOT NULL,
`ma_stock` int(11) NOT NULL,
`ma_created_ur_id` int(11) NOT NULL,
`ma_created_timestamp` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Abfrage:
SELECT
habe folgende Tabelle und möchte gerne alle Datensätze gruppiert nach Location und Produkten haben, welche zuletzt bearbeitet worden sind in einem bestimmten Jahr.
Wenn ich diese Abfrage nun mit MySQL 5.5.46 (Installiert auf Server) oder 5.5.32 (Laptop mit Xampp 1.8.2) durchführe, so kommt es zu keinem Ergebnis (es wird nur geladen und geladen....).
Führe ich die Abfrage nun mit meinem Rechner aus, auf welchem Xampp 7.0.3 mit 10.1.10-MariaDB installiert ist, so ist das Ergebnis nach 0.03sek da.
Mit der Abfrage müsste MySQL eigentlich gut zurecht kommen. Weiß jemand rat?
Tabelle:
CREATE TABLE `material_account` (
`ma_id` int(11) NOT NULL,
`ma_produkt_id` int(11) NOT NULL,
`ma_location_id` int(11) NOT NULL,
`ma_stock` int(11) NOT NULL,
`ma_created_ur_id` int(11) NOT NULL,
`ma_created_timestamp` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Abfrage:
SELECT
ma_id,
ma_location_id,
ma_product_id,
ma_stock,
ma_created_ur_id,
ma_created_timestamp
FROM ma_location_id,
ma_product_id,
ma_stock,
ma_created_ur_id,
ma_created_timestamp
material_account
WHERE (ma_location_id, ma_product_id, ma_created_timestamp) IN (
ORDER BY SELECT
ma_mat_id,
ma_mp_id,
MAX(ma_created_timestamp)
FROMma_mp_id,
MAX(ma_created_timestamp)
material_account
WHERE date_format(ma_created_timestamp, '%Y') = '2015'
GROUP BY ma_location_id,
ma_product_id)
ma_product_id)
ma_location_id ASC,
ma_product_id ASC
ma_product_id ASC