Getting first two records in MySQL query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
flycast
Forum Commoner
Posts: 37
Joined: Wed Jun 01, 2005 7:33 pm

Getting first two records in MySQL query

Post by flycast »

I have a select query that is returning many records and want only the first two records. How do I do this?
SELECT event.*, location.place, seminar.name, seminar.shortdescription, seminar.longdescription, seminar.keywords
FROM event, location, rel_location, rel_seminar, seminar
where (event.id = rel_location.event and rel_location.location = location.id)
and (event.id = rel_seminar.event and rel_seminar.seminar = seminar.id)
and event.display = 1
and event.eventdate > "2006-01-15"
order by indexorder asc, eventdate asc
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Append " LIMIT 2" to your SQL.
(#10850)
flycast
Forum Commoner
Posts: 37
Joined: Wed Jun 01, 2005 7:33 pm

Post by flycast »

:oops: Forgot about "Limit"
Thanks!
Post Reply