2017-02-27 28 views
-2

我有這樣的數據的基礎結構:如何選擇相對SQL一列到另一

structure

字段id是主鍵。我試圖找到所有有department='civil' & level=4的課程。

+1

'SELECT * FROM yourTable WHERE department ='civil'AND level = 4' –

+4

你應該查看一個很好的SQL教程來學習基礎知識。這不是學習SQL的好方法。 –

+0

好的,非常感謝。很好的工作 –

回答

0

@kousik曼達爾的答案是正確的。但是讓我簡單介紹一下它的工作原理。 (因爲你顯然沒有先看到在線)

SELECT course_name  -- This is the column that you will recieve. if you pick * instead of course_name it will select all columns which match the criteria. 
FROM table_name   -- you select the course_name from the table 'table_name' 
WHERE department='civil' -- This will select columns where the department column has 'civil' as a value 
AND level=4    -- This will also check if the level equals to 4. 

這可能沒有那麼有用,因爲答案已經給出。但我希望它會給你學習一些有用的信息SQL

+0

謝謝你的幫助。 –

0

試試這個,

select course_name from table_name where department='civil' and level=4 
+1

謝謝,那是另一種方式。 –