Wir benötigen Zeile zu erhalten, wenn product_id
in der Reihenfolge ist.MySql get Zeile, wenn ID in der Reihenfolge ist
Tabelle (Produkt)
product_id name
1 Parle
2 Coconut
3 Pizza
4 Colgate
5 Ice Cream
6 Nuts
8 Britania
9 Pepsi
Erfordern Ausgabe
product_id name
1 Parle
2 Coconut
3 Pizza
4 Colgate
5 Ice Cream
6 Nuts
product_id - 8 and 9
nicht bekommen, weil sie nicht in der Reihenfolge ist.
Mein
select distinct t1.*, t1.product_id, (select GROUP_CONCAT(t2.product_id) from product as t2) as p_id
from product t1
having FIND_IN_SET(t1.product_id+1, p_id)
Ausgabe
product_id name
1 Parle
2 Coconut
3 Pizza
4 Colgate
5 Ice Cream
In diesem Versuch versuche ich nicht
product_id - 6
Reihe bin immer.Hinweis: Ich möchte
MySql
Abfrage nicht inPHP
.
Vielen Dank!
Sie fügen Ihrer Produkt-ID eine Gruppierungseigenschaft hinzu, die in einer separaten Spalte besser aufgehoben wäre. – jeroen
Von wo wird die Sequenz gestartet? –
Nur 1 bis 6 Zeilen nichts anderes. –