Ich habe eine Tabelle wie BelowMySQL Sortieren nach zwei Spalten
CREATE TABLE Products(Product_id INT, ProductName VARCHAR(255), Featured enum('Yes', 'No'), Priority enum('p1', 'p2', 'p3')) INSERT INTO Products(ProductName, Featured, Priority) VALUES('Product A', 'Yes', 'p1'), ('Product B', 'No', 'p2'), ('Product C', 'Yes', 'p1'), ('Product D', 'No', 'p1'), ('Product E', 'Yes', 'p3'), ('Product F', 'No', 'p2'), ('Product G', 'Yes', 'p1'), ('Product H', 'Yes', 'p2'), ('Product I', 'No', 'p2'), ('Product J', 'Yes', 'p3'), ('Product K', 'Yes', 'p1'), ('Product L', 'No', 'p3');
Ich brauche die Ausgewählte Produkte von Produkt mit Priorität P1, P2 und P3
Op: ProdName | Featured | Priority Product A Yes p1 Product C Yes p1 Product G Yes p1 Product K Yes p1 Product H Yes p2 Product E Yes p3 Product J Yes p3 Product D No p1 Product B No p2 Product F No p2 Product I No p2 Product L No p3
ich unten Schrieb eine Abfrage gefolgt zu bekommen welche funktioniert nicht ..
SELECT * FROM Products ORDER BY Featured IN ('Yes') desc, Priority IN ('p1', 'p2', 'p3') desc
könnte u plz Stelle Fehler in diesem
Welchen Fehler sehen Sie? die Aussage, wie du sie geschrieben hast, sollte funktionieren, und so sollte das vereinfachte Yogendra Singh empfehlen. Wählen Sie nur Spalte Product_id aus? In Ihrem Beispiel wird alles NULL sein. – Yuri
Mögliches Duplikat [PHP MySQL Sortieren nach zwei Spalten] (http://stackoverflow.com/questions/514943/php-mysql-order-by-two-columns) –