[MySQL] Query syntax error?

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

Moderator: General Moderators

nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

Re: [MySQL] Query syntax error?

Post by nutkenz »

astions wrote:The logic of your query is way off and it's missing aliases. Post your table structure and what your trying to accomplish.
The structure is irrelevant because it's for a pagination class which should work on every single database.

I solved it like this:

Code: Select all

if (empty($group))
{
    $dbRCount = $db->get_var("SELECT COUNT(*) AS total $from $where");
}
else // Multiple rows will be returned
{
    $dbRCount = count($db->get_col("SELECT COUNT(*) AS total $from $where $group"));
}
Not the most efficient way probably, but the speed is OK.
Post Reply