using fieldnames in LIMIT clause

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
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

using fieldnames in LIMIT clause

Post by kendall »

Can you use a fieldname whose data type is INT in a LIMIT clause?

I am conducting the following subquery statement
[sql]SELECT FirstName, LastName, EmailAddress, (SELECT s.code FROM      northstar_access_codes AS s      WHERE s.type = 'readwrite'      ORDER BY RAND() LIMIT 0,COUNT(`readwriteclasses`)) AS RWCode, (      SELECT s.code      FROM northstar_access_codes AS s      WHERE s.type = 'learnspeak'      ORDER BY RAND() LIMIT 0,COUNT(`learnspeakclasses`)) AS LSCode, (      SELECT t.code      FROM northstar_access_codes AS t      WHERE t.type = 2      ORDER BY RAND() LIMIT 1) AS TeacherCode      FROM crm_contacts1, northstar_information      WHERE AccountID = contactid AND AccountID IN('%s')      AND northstar_informaton.`Status` = 1[/sql]
where `learnspeakclasses` is an INT field in northstar_information. Can I use fieldnames and values in this manner?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: using fieldnames in LIMIT clause

Post by Weirdan »

No, you can only use constants in limit clause
Post Reply