if i'm understanding what you mean, it seems like you're getting a little
too complicated.
select Title, IF(Title LIKE "%TOMMY%", 1, 0) as check
from inv where...
... order by check desc, Title
this will return rows like this:
+-------------+-------+
| title | check |
+-------------+-------+
| a | 1 |
| b | 1 |
| c | 1 |
| w | 1 |
| z | 1 |
| a | 0 |
| h | 0 |
| z | 0 |
+-------------+-------+
i.e. each subset (check=1 and check=0) sorted alphabetically.
-ravi.
-----Original Message-----
From: Carl Schrader [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 04, 2001 12:13 PM
To: Ravi Raman
Cc: [EMAIL PROTECTED]
Subject: Re: Query Question
Close. Now I need to get the order correct. I need the order like
Tommy
Tommy Lee
Baseball (matched with Tommy in the Content or Notes field)
World Series (matched with Tommy in the Content or Notes field)
I've been playing with something like:
select Title, concat(IF(Title LIKE "%TOMMY%", 1, 0),LPAD(90-ASCII(left
(Title,1)),2,'0')) as check
from inv where (Title LIKE 'tommy%') OR (Content LIKE '%tommy%') OR (Notes
LIKE
'%
tommy%') order by check desc
but that doesn't get it close enough. Only compares the frist char in Title.
I
need a more robost idea...
Ravi Raman wrote:
> hi.
>
> select Title, IF(Title LIKE "%TOMMY%", 1, 0) as check
> from inv where...
> ... order by check desc;
>
> hth.
> -ravi.
>
> -----Original Message-----
> From: Carl Schrader [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 04, 2001 10:30 AM
> To: [EMAIL PROTECTED]
> Subject: Query Question
>
> I'm doing a query like:
>
> select Title from inv where Title LIKE '%TOMMY%' OR Content LIKE
> '%TOMMY%' OR Notes LIKE '%TOMMY%' order by Title
>
> What I need is to have the results that match Title LIKE '%TOMMY%' to
> appear first and then the rest. I have been doing 2 separate queries and
>
> filtering the first results from the second in a script. I would like to
>
> do this with a single query. Can that be done?
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php