Re: Doing sorting that is case insensitive

Russ Tyndall <[email protected]> Mon, 14 Feb 2011 07:44:13 -0500
Newsgroups gmane.lisp.clsql.general
Message-ID <[email protected]>
I dont know about that syntax and that doesnt seem like the correct way
to handle case insensitive ordering.

But, to get arbitrary syntax you can use the sql-expression function as
follows:
(clsql:select [id]
        :from [wp_posts]
        :limit 10
        :order-by
        (clsql-sys:sql-expression :string "post_title DESC binary"))

Which would produce this (invalid for my mysql) syntax:
  SELECT id FROM WP_POSTS ORDER BY post_title DESC binary LIMIT 10

That said, if you chose a case insensitive collation (such as
utf8-general-ci) for your database/table, ordering and string matching
would be case insensitive by default. 

The easiest, general way to achieve case insensitive sorting is probably
the upper function:
(clsql:select [id]
        :from [wp-posts]
        :limit 10
        :order-by [upper [post-title]])


HTH,
Russ Tyndall



On 2/12/2011 5:41 PM, Mackram Raydan wrote:
> Hey Everyone,
>
> I was just wondering if there was a way to make clsql requests be case 
> insensitive specifically when doing an order-by. My understanding that 
> adding the word binary right after the order section of a mysql 
> statement will force mysql to do the sorting as case insensitive so is 
> there a way to tell the select function in clsql to add that binary 
> directive.
>
> I have only done a search on Google about the subject and have came up 
> empty handed (ie I did not have time yet to read the code). So any help 
> that could save me some time would be much appreciated.
>
> Thanks in advance.
>
> Mackram Raydan
> _______________________________________________
> CLSQL mailing list
> [email protected]
> http://lists.b9.com/cgi-bin/mailman/listinfo/clsql