Does anyone know how to select entries from SQL table where first record from column A equals X and select other 5 random (1-10) records from the same column.
I need to retrieve in total 6 entries by one SQL query, where first entry is always static and other five random.
tbl cars
ID COLOUR CAR
1 green carX
2 blue carX
3 green carY
4 red carZ
5 black carA
6 yellow carB
7 black carB
Required result:
first record of carX, blue(static)
and 5 random
all records should be different from each other – unique
You could use a UNION to
SELECTthe static row and combine it with aSELECTof the random rows provided you have a specific condition.Note: If you don’t have trouble with the static condition, comment back with more detail about your the static record.