FeedForAll Forum Index  
 Home  •  FAQ  •   Search   •  Register   •  Profile   •  Log in
Search found 1 match
Author Message
Topic: Problem in mysql when ordering by more than one column usin
johndavid

Replies: 1
Views: 8108

PostForum: SQL2RSS (MySQL to RSS Feed Creator)   Posted: Tue Aug 04, 2009 3:42 am   Subject: Problem in mysql when ordering by more than one column usin
Hi,

I have a MySQL query where I sort by field like this:

"... WHERE (patterns.id IN($idsJoin)) $where
ORDER BY FIELD($idsJoin2) LIMIT 0 , $numLines";

where $idsJoin2 is something like this:

my $idsJoin = join(',',@ids);
my $idsJoin2="patterns.id, ".$idsJoin;

and "@ids is an array with numbers I want to order by.

The thing is that after ordering by $idsJoin2, I want to order by another columns, like this:

"WHERE (patterns.id IN($idsJoin)) $where
ORDER BY FIELD($idsJoin2), products.product, versions.version, builds.build LIMIT 0 , $numLines";

If I put that columns before ORDER BY FIELD it sorts by them with any problem, but if they are after the ORDER BY FIELD, which is what I want, it just ignores them and just sorts by the ORDER BY FIELD statement.

I don't see why is this happening. Any idea? Thanks.
 

 Jump to:   


Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme