標題:
資料庫查詢語法
[打印本頁]
作者:
may
時間:
2013-7-4 20:44
標題:
資料庫查詢語法
SELECT * FROM `contactinfo_tab`;
--------------------------------------------------------------------------------
SELECT `ci_name` FROM `contactinfo_tab`;
--------------------------------------------------------------------------------
SELECT * FROM `contactinfo_tab`
WHERE `ci_id` = '9';
--------------------------------------------------------------------------------
SELECT * FROM `contactinfo_tab`
WHERE `ci_id` = '2'
OR `ci_id` = '4';
--------------------------------------------------------------------------------
SELECT * FROM `contactinfo_tab`
WHERE `ci_id` BETWEEN '2' AND '5';
--------------------------------------------------------------------------------
SELECT * FROM `contactinfo_tab`
WHERE `ci_address` LIKE '%三民區%';
--------------------------------------------------------------------------------
SELECT COUNT(*) AS `num`
FROM `contactinfo_tab`;
--------------------------------------------------------------------------------
SELECT COUNT(*) AS `num`
FROM `contactinfo_tab`
WHERE `ci_address` LIKE '%三民區%';
--------------------------------------------------------------------------------
SELECT * FROM `contactinfo_tab`
ORDER BY `ci_birthday` DESC;
--------------------------------------------------------------------------------
SELECT * FROM `contactinfo_tab`
ORDER BY `ci_address` DESC , `ci_id` DESC;
--------------------------------------------------------------------------------
SELECT * FROM `contactinfo_tab`
LIMIT 1 , 5
--------------------------------------------------------------------------------
-- 若開始位置為0時, 可忽略--
SELECT * FROM `contactinfo_tab`
LIMIT 0 , 5
可寫成
SELECT * FROM `contactinfo_tab`
LIMIT 5
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2