Select id, mon1, mon2 From MyTable
UNION
Select id, mon2, mon3 From MyTable
UNION
Select id, mon3, mon4 From MyTable
UNION
Select id, mon4, mon5 From MyTable
Order by 1,2,3;
"The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb
Select id, mon1, mon2 From MyTable
UNION
Select id, mon2, mon3 From MyTable
UNION
Select id, mon3, mon4 From MyTable
UNION
Select id, mon4, mon5 From MyTable
Order by 1,2,3;
thanks for your hint, but it's not working the way I need it.
because the amount of values in the table1 is not always the same...sometimes there are 3, 5, or 7 values or more in a single row...
a row contains sometimes 4, sometimes 5, or 3, 6,7,8 values.
As mentioned above this is not because of a bad design.
A short explanation:
these values are just objects of different routes - some routes have only 3 monizoring objects, another 4, or 5...etc.
As soon as 1 route failed - every 10 minutes a token is send - the result is the route where the token has been failed.
Ok try this one (assuming there are no gaps (nulls) in the middle of route):
PHP Code:
Select Id, Mon1, Mon2 From Mytable
Union
Select Id, Mon2, Mon3 From Mytable
Where Mon3 Is Not Null
Union
Select Id, Mon3, Mon4 From Mytable
Where Mon4 Is Not Null
Union
Select Id, Mon4, Mon5 From Mytable
Where Mon5 Is Not Null
Order By 1,2,3;
PS: Union all will make no difference unless routes are duplicate.
"The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb
Bookmarks