English | 正體中文 | 简体中文

SQL where


范例资料表 : Songs (以下范例皆用此表当作资料来源)
Artist SongTitle SongPlayCount
Scott Mckenzie San Francisco 30
Kiss Detroit rock city 120
R.E.M. Losing my religion 256
Pink Try 97


Example
选择出符合搜寻值的资料列

Sytax :SELECT * FROM table_name WHERE search_condition
SQL
SELECT * FROM Songs WHERE Artist = 'Scott Mckenzie'

会输出结果
Artist SongTitle SongPlayCount
Scott Mckenzie San Francisco 30


Example
选择出栏位'SongPlayCount'大于100的资料列

Sytax : SELECT * FROM table_name WHERE search_column > criteria_number
you can also use >(greater than), >= (greater than or equal to), < (less than), <=(less than or equal to), = (equal to), <> (not equal to)

SQL
SELECT * FROM Songs WHERE SongPlayCount > 100

会输出结果
Artist SongTitle SongPlayCount
Kiss Detroit rock city 120
R.E.M. Losing my religion 256


Example
选择出'SongTitle'等于'San Francisco'的资料列

Sytax : SELECT * FROM table_name WHERE search_column = criteria_string
SQL
SELECT * FROM Songs WHERE SongTitle = 'San Francisco'

会输出结果
Artist SongTitle SongPlayCount
Scott Mckenzie San Francisco 30

© 2012 PureExample.com contact