sql-servert-sqlmultiple-select-query

SQL multiple select rows


Name | Status      | value
-----+-------------+-------
wec1 | rotortemp   | Null
wec1 | baldetemp   | Null
wec1 | Cabinettemp | 1
wec2 | rotortemp   | Null
wec2 | baldetemp   | Null
wec2 | Cabinettemp | Null

How can I select all the wec1 because the value of one row of wec1 is = 1


Solution

  • Try this:

    SELECT *
    FROM TableName
    WHERE Name IN (SELECT Name
                   FROM TableName
                   WHERE value=1)