For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > August 2006 > Sort and Order by









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Sort and Order by
weetat.yeo@gmail.com

2006-08-10, 9:58 pm

Hi ,
I have some other issue regarding sort in MYSQL .

I have 2 table , tbl_chassis and tbl_card .
In tbl_chassis , the primary key is serial_no and In tbl_card the
primary key is serial_no.
The serial_no in tbl_chassis are link to serial_no in tbl_card.
For example ,

tbl_chassis
serial_no model
123 w123
890 ws890
345 cx1290

tbl_card
serial_no card_model
123 wx-123456
123 ab-123
123 wz-890
890 z-c123
890 cd-290
345 d123
345 ws-8901

I would like to order by model columns in tbl_chassis then order by
card_model in tbl_card . I have sql below but it not working at all :
Any idea how to sort columns in different table. Thanks

The data should display as shown below if sort by desc

123 ab-123
123 wz-890
123 wx-123456
345 d123
345 ws-8901
890 cd-290
890 z-c123

SELECT
DISTINCT(tbl_chassis.serial_no),tbl_chassis.host_name,tbl_chassis.chasis_sw_version,tbl_chassis.chasis_model,tbl_chassis.chasis_flash_size,tbl_chassis.chasis_dram_size,tbl_chassis.country,tbl_chassis.city,tbl_chassis.building,
tbl_chassis.other,tbl_chassis.status,tbl_chassis.chasis_eos,tbl_chassis.chasis_eol,tbl_chassis.chasis_user_field_1,tbl_chassis.chasis_user_field_2,tbl_chassis.chasis_user_field_3
from tbl_chassis tbl_chassis,tbl_card tbl_card WHERE
tbl_chassis.serial_no = tbl_card.serial_no AND lower(country) =
lower(trim('Singapore')) ORDER BY tbl_card.card_model asc

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com