Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
siropchik
Forum Newbie
Posts: 3 Joined: Thu Jul 29, 2004 1:47 am
Post
by siropchik » Thu Jul 29, 2004 1:47 am
Hi,I have very strange problem .My big table consists of many records ,part of them is null or empty value .Now a problem:
Then I do Order By 'Some Column_Name' I receive an answer but in wrong way :First of all -it's a empty fields and at finish Results that i need.
Probably you know how can I redirect an answer.
First my search value,after empty fields????
Thanks
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jul 29, 2004 1:50 am
Code: Select all
ORDER BY `column` WHERE `column` NOT NULL?
Draco_03
Forum Regular
Posts: 577 Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada
Post
by Draco_03 » Thu Jul 29, 2004 9:07 am
You could also put some sort of validation
For exemple if you put first name REQUIRed, well you won't have null field..
(note that this is in the case that you have UNWANTED NULL fields..)
siropchik
Forum Newbie
Posts: 3 Joined: Thu Jul 29, 2004 1:47 am
Post
by siropchik » Sun Aug 01, 2004 2:01 am
Yes,I have to have NULL fields too,but in the end
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 01, 2004 2:08 am
if you can perform unions, I'd use one, the first select grabs the non-null ones, the second only the null ones..
siropchik
Forum Newbie
Posts: 3 Joined: Thu Jul 29, 2004 1:47 am
Post
by siropchik » Sun Aug 01, 2004 8:24 am
it works but
first: it not sort right;
second: this query has 14 seconds
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 01, 2004 10:31 am
it may be better to sort it yourself then.