Master Ruby/Rails Programming
Notes to self
Wednesday, January 16, 2008
Select a random record from a DB table
In Rails:
Post.find(:first, :order => "rand()")
In SQL:
SELECT * FROM posts ORDER BY RAND() LIMIT 1;
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Blog Archive
►
2010
(2)
►
April
(1)
►
March
(1)
►
2009
(6)
►
September
(2)
►
March
(1)
►
February
(2)
►
January
(1)
▼
2008
(51)
►
December
(1)
►
November
(2)
►
October
(2)
►
September
(3)
►
August
(1)
►
July
(2)
►
June
(2)
►
May
(3)
►
April
(3)
►
March
(12)
►
February
(12)
▼
January
(8)
What was Sun missing? DB => MySQL
Add methods to an instance
Select a random record from a DB table
Removing instance variables
Bug Severity and Priority definitions
Struct
Create a project using earlier versions of Rails
Undocumented Rails features - render collection wi...
No comments:
Post a Comment