พบกับบทความเกี่ยวกับคอมพิวเตอร์และ programming ได้ที่ http://articles.modoeye.com
PHP development / tb_news 10 reccord
narakorn
narakorn
Sat 26 Jan 2008 00:17:52
คือ​  ​ต้อง​การ​  SELECT ​ข้อมูล​จาก​ tb_news  10 reccord ​สุดท้ายครับ
แต่​เวลา​แสดง​ให้​แสดง​ 10  reccord นั้น randdom ​ทีละ​ 1 record ​ครับ​ ​พี่ๆ​ท่านชี้​แนะ​ด้วย​ครับ ผมไม่แน่ใจว่าเข้าใจไรผิดไปหรือ ป่าวครับ ชี้แนะด้วยครับ
webmaster
webmaster
Sat 26 Jan 2008 02:03:22
ก็ใช้ sub query เอาครับ
SELECT...... LIMIT 10 ORDER BY .... ได้อะไรมาก็เอามาใส่

SELECT ..... FROM (SELECT ...... LIMIT 10 ORDER BY .....) AS sub LIMIT 1 ORDER BY RAND()

อย่าลืมทำการ alias ด้วยนะครับไม่อย่างนั้นจะไม่ผ่าน เนื่องจากไม่สามารถสร้าง reference table ได้
Reply
Name:
E-mail:
Home | Services | Forum | Classified | Directories | Support | Contact
ATOM feed RSS 0.9 feed RSS 1.0 feed RSS 2.0 feed
Copyright © 2005 - 2007 Modoeye.com, All Rights Reserved.
Disclaimer | Privacy policy | Term of Use | Term of Services
Valid XHTML Valid CSS! PHP: Hypertext Preprocessor MySQL database Apache Powered! FreeBSD Power to serve
Modoeye Sitemap Client login