從命令提示符中讀取數(shù)據(jù)
我們將在SQL SELECT語句使用WHERE子句來讀取MySQL數(shù)據(jù)表 tutorials_tbl 中的數(shù)據(jù):
實例
以下實例將讀取 tutorials_tbl 表中 tutorial_author 字段值為 Sanjay 的所有記錄:
root@host# mysql -u root -p password; Enter password:******* mysql> use TUTORIALS; Database changed mysql> SELECT * from tutorials_tbl WHERE tutorial_author='Sanjay'; +-------------+----------------+-----------------+-----------------+ | tutorial_id | tutorial_title | tutorial_author | submission_date | +-------------+----------------+-----------------+-----------------+ | 3 | JAVA Tutorial | Sanjay | 2007-05-21 | +-------------+----------------+-----------------+-----------------+ 1 rows in set (0.01 sec) mysql>
除非你使用 LIKE 來比較字符串,否則MySQL的WHERE子句的字符串比較是不區(qū)分大小寫的。 你可以使用 BINARY 關(guān)鍵字來設(shè)定WHERE子句的字符串比較是區(qū)分大小寫的。
如下實例
root@host# mysql -u root -p password; Enter password:******* mysql> use TUTORIALS; Database changed mysql> SELECT * from tutorials_tbl \ WHERE BINARY tutorial_author='sanjay'; Empty set (0.02 sec) mysql>
2015職稱計算機考試書PowerPoint2007中 .. 定價:¥45 優(yōu)惠價:¥42 更多書籍 | |
2015年全國職稱計算機考試教材(2007模 .. 定價:¥225 優(yōu)惠價:¥213 更多書籍 |