php - MySQL Query with one-to-many -
i new mysql , need query here sample data columns:
modelid styleid sequence 19463 316811 0 19463 316812 1 19463 316813 2 19463 316814 3 19463 316920 4 19463 316921 5 19727 318010 0 19727 318011 2 19727 318012 1 19727 318013 3 19884 320053 0 19884 320054 1 19884 320055 2 19884 320056 3 19998 321302 0 19998 321303 1 19998 321304 2 19998 321305 3 19998 321306 4 19998 321307 5 19998 321308 6 19998 321309 7
i need 1 styleid every modelid, preferably sequence of 0 or 1, sequence not matter, can random.
the best result this, cant use sequence = 0 clause though:
modelid styleid sequence 19463 316811 0 19727 318010 0 19884 320053 0
thanks
try this
select modelid, max(styleid),min(sequence) mytable group modelid
Comments
Post a Comment