In a switching valve containing a valve member for opening and closing a
valve seat and a piston for driving the valve member by the action of a
pilot fluid pressure inside a valve housing, a magnet for positional
detection is attached to the piston, two sensor attachment grooves
extending in the direction of the axial line L of the switching valve and
having different groove lengths in accordance with the operational
position are formed in parallel on the side face of the valve housing,
and magnetic sensors are attached at locations on the side of the
innermost end wall in the attachment grooves.