ben Seçme öncelik p1, p2 ile ürünün ardından ürün ve p3MySQL al
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 p3almak gerekiyor
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');Aşağıda
aşağıda bir sorgu yazdım bir tablo gibi sahip hangi çalışmıyor ..
SELECT * FROM Products ORDER BY Featured IN ('Yes') desc, Priority IN ('p1', 'p2', 'p3') desc
olabilir o
u plz nokta hataNo
önce görünür bu
Yes
yaparak
SELECT *
FROM Products
ORDER BY Featured desc,
Priority asc;
:
Hangi hatayı görüyorsunuz? Yazdığınız gibi deyim işe yaramalıdır, ans böylece Yogendra Singh'in önerdiği sadeleştirilmiş olmalıdır. Sadece Product_id sütunu seçiyor musunuz? Örneğinizde bütün NULL'lar olacak. – Yuri
Olası iki kopyası [PHP MySQL Order by Two Columns] (http://stackoverflow.com/questions/514943/php-mysql-order-by-two-columns) –