RE: [PHP] Re: Using PHP for NULLs

2002-05-20 Thread Jay Blanchard

[snip]
I do believe it is a MySql question!!

What's wrong with the old standard way as:

$result = mysql_query(
SELECT *,
if (last_name is NULL,'zzz end',last_name) as last_name_sort
FROM   new_miatapix
ORDER BY last_name_sort
LIMIT $page, 20);

$result = mysql_query(SELECT * FROM new_miatapix ORDER
BY last_name LIMIT $page, 20);
[/snip]

And then there is the very old standard;

SELECT *
FROM new_miatapix
ORDER BY last_name DESC
LIMIT $page 20

HTH!

Jay


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: Using PHP for NULLs

2002-05-18 Thread Jason Soza

Thanks for the help! I spent more time looking at IFNULL() when I should've
just been looking at IF(). Thanks again, sorry for the off-topic!

Jason Soza

-Original Message-
From: Dan Koken [mailto:[EMAIL PROTECTED]]
Sent: Saturday, May 18, 2002 11:16 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Using PHP for NULLs


I do believe it is a MySql question!!

What's wrong with the old standard way as:

$result = mysql_query(
SELECT *,
if (last_name is NULL,'zzz end',last_name) as last_name_sort
FROM   new_miatapix
ORDER BY last_name_sort
LIMIT $page, 20);


Good Luck.. HTH..
Dan..
===
Jason Soza wrote:

 I thought this was a MySQL question, or something that could be solved
using
 a creative SQL string, but after looking through the MySQL manual, I don't
 think I can handle this with the database alone. According to the manual,
 MySQL always sorts NULL values first - I want them last. I have a
last_name
 field that sometimes contains people's last names, sometimes they choose
not
 to enter their last names. I want those who don't enter a last name to end
 up last on the list.

 Right now I have: $result = mysql_query(SELECT * FROM new_miatapix ORDER
BY
 last_name LIMIT $page, 20);

 Am I going to have to do two queries here, then store them somehow using
an
 array? It seems like I'm going to have to do one query to get all NULL
 values for last_name, then do another query to get all NOT NULL values for
 last_name, but how would I handle that after I get it to PHP?

 Or can I use some PHP function to sort $result to place all NULL values
 last? I'd check the PHP manual, but it seems to not be responding well at
 the moment.

 Thanks,

 Jason Soza




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php