Hi there,
I'm having a problem on my complicated query.
My question is similar to the question in a couple of emails earlier in
this mailing list which subject's is "complicated query".

I got 3 tables below.

<test1> table
+----+------+
| id | name |
+----+------+
|  1 | fumi |
|  2 | ali  |
|  3 | ton  |
+----+------+

<test2> table
+----+--------+-------+
| id | maker  | price |
+----+--------+-------+
|  1 | fum111 |   102 |
|  3 | ton222 |   150 |
+----+--------+-------+

<test3> table
+----+----------+
| id | location |
+----+----------+
|  3 | LA       |
+----+----------+

when I commit my query "select test1.*,test2.*,test3.* from test1 left join test2 on 
test1.id = test2.id left join te
st3 on test1.id = test3.id;",I get this table below.
+----+------+------+--------+-------+------+----------+
| id | name | id   | maker  | price | id   | location |
+----+------+------+--------+-------+------+----------+
|  1 | fumi |    1 | fum111 |   102 | NULL | NULL     |
|  2 | ali  | NULL | NULL   |  NULL | NULL | NULL     |
|  3 | ton  |    3 | ton222 |   150 |    3 | LA       |
+----+------+------+--------+-------+------+----------+

Now I wanna sort this table by smaller price. (I want NULL to be at the last)
so I made a new query " select test1.*,test2.*,test3.* from test1 left join test2 on 
test1.id = test2.id left join te
st3 on test1.id = test3.id  order by (price is null);" according to a couple
of email earlier in this mailing list.

I get the table below.
+----+------+------+--------+-------+------+----------+
| id | name | id   | maker  | price | id   | location |
+----+------+------+--------+-------+------+----------+
|  3 | ton  |    3 | ton222 |   150 |    3 | LA       |
|  1 | fumi |    1 | fum111 |   102 | NULL | NULL     |
|  2 | ali  | NULL | NULL   |  NULL | NULL | NULL     |
+----+------+------+--------+-------+------+----------+

In a price column, NULL is at the last, so it's okay, BUT !!
150 is upper than 102 !! I want smaller price to show up upper and
finally NULL.

I've tried many queries , but couldn't find out...
anybody can give me a hint or answer ?

Thank you for reading till here.

Fumitada.

---------------------------------------------------------------------
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

Reply via email to