2016-02-04 245 views
-1

我有一個像這樣提取數據

user_id| Year | Math |English| Computer | Accounting| 
-------|-------|------|-------|----------|-----------| 
    1  12  0  1  0   1 

SQL表所以我只想其值爲1就例如受試者我希望它解壓到echouser 1 is in year 12 and takes English and Accounting

我怎麼能做到這一點我完全失去了

+3

糟糕的表格設計......有一個班級專欄和幾個行,而不是幾個欄和一個行。 (也許需要另一個表格。) – jarlh

回答

-1

您可以嘗試一個簡單的查詢,如:

select * from `TABLE` where `math`=1 or `english`=1 or `computer`=1 or `accounting`=1; 

用實際表名替換TABLE

+0

這仍然會選擇所有列。 – mrun