Board logo

標題: 資料庫查詢語法 [打印本頁]

作者: may    時間: 2013-7-4 20:44     標題: 資料庫查詢語法

  1. SELECT * FROM `contactinfo_tab`;
  2. --------------------------------------------------------------------------------
  3. SELECT `ci_name` FROM `contactinfo_tab`;
  4. --------------------------------------------------------------------------------
  5. SELECT * FROM `contactinfo_tab`
  6. WHERE `ci_id` = '9';
  7. --------------------------------------------------------------------------------
  8. SELECT * FROM `contactinfo_tab`
  9. WHERE `ci_id` = '2'
  10. OR `ci_id` = '4';
  11. --------------------------------------------------------------------------------
  12. SELECT * FROM `contactinfo_tab`
  13. WHERE `ci_id` BETWEEN '2' AND '5';
  14. --------------------------------------------------------------------------------
  15. SELECT * FROM `contactinfo_tab`
  16. WHERE `ci_address` LIKE '%三民區%';
  17. --------------------------------------------------------------------------------
  18. SELECT COUNT(*) AS `num`
  19. FROM `contactinfo_tab`;
  20. --------------------------------------------------------------------------------
  21. SELECT COUNT(*) AS `num`
  22. FROM `contactinfo_tab`
  23. WHERE `ci_address` LIKE '%三民區%';
  24. --------------------------------------------------------------------------------
  25. SELECT * FROM `contactinfo_tab`
  26. ORDER BY `ci_birthday` DESC;
  27. --------------------------------------------------------------------------------
  28. SELECT * FROM `contactinfo_tab`
  29. ORDER BY `ci_address` DESC , `ci_id` DESC;
  30. --------------------------------------------------------------------------------
  31. SELECT * FROM `contactinfo_tab`
  32. LIMIT 1 , 5
  33. --------------------------------------------------------------------------------
  34. -- 若開始位置為0時, 可忽略--
  35. SELECT * FROM `contactinfo_tab`
  36. LIMIT 0 , 5
  37. 可寫成
  38. SELECT * FROM `contactinfo_tab`
  39. LIMIT 5
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2