RE: [PHP-DB] Order By [blank]

2006-12-21 Thread Naintara
Depending on your MySQL version you could use a subquery by combining the two queries you mentioned, for a fairly straight-forward query. http://dev.mysql.com/tech-resources/articles/4.1/subqueries.html http://mysqld.active-venture.com/Subqueries.html You could read about optimizing subqueries

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread Kevin Murphy
Unfortunately, I'm on 4.0.x so sub-queries are out. And yeah, I should get my host to upgrade but we both work for the government so that isn't happening. ;-) Any other thoughts. -- Kevin Murphy Webmaster: Information and Marketing Services Western Nevada Community College www.wncc.edu

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread David Mitchell
What about a union? Does mySql 4.0.x support it? select * from blank where tchar_10 != '' union all select * from blank where tchar_10 = '' - Dave On 12/21/06, Naintara [EMAIL PROTECTED] wrote: Depending on your MySQL version you could use a subquery by combining the two queries you

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread tg-php
This is a little weird looking, but should do the job. Remember that items in your 'order by' can be manipulated conditionally. In this case, I'm looking for NULL as well as '' (empty) and changing it to something that should come after all your normal alphabetical values, but it doesn't

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread tg-php
This is a little weird looking, but should do the job. Remember that items in your 'order by' can be manipulated conditionally. In this case, I'm looking for NULL as well as '' (empty) and changing it to something that should come after all your normal alphabetical values, but it doesn't

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread David Mitchell
In case the blank is a null or is really a blank: select * from blank where tchar_10 is not null and tchar_10 != '' union all select * from blank where tchar_10 is null or tchar_10 = '' - Dave On 12/21/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: This is a little weird looking, but should

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread tg-php
You shouldn't have to do that. the IFNULL() handles all that. If the item is null, it returns an emptry string ''. If it's blank/empty, it returns an empty string. This is just used for the comparison = ''. This determines if it's empty or null and if so, returns

Re: [PHP-DB] Order By [blank]

2006-12-21 Thread Kevin Murphy
I haven't tried the union method the query i have is actually quite a bit more complicated than just a simple select * from a single table, so while it may work, it might take a while to write it if I am reading all this right. But yes, the ifnull() method works just fine. Thanks for