Jump to content

[SOLVED] SQL Query sorted by 3 columns


DJ Unique

Recommended Posts

Hi,

 

I want to right a sql query that will sort 2 columns alphabetically, and then only show the results from the last 50 entries. How can I do this?

 

This is what I have so far:

 

SELECT * FROM manufacturer_detail INNER JOIN handset_detail ON manufacturer_detail.manufacturer_detail_id=handset_detail.manufacturer_detail_id
INNER JOIN handset_type ON handset_detail.handset_code=handset_type.handset_code $where ORDER BY manufacturer_name, handset_model

Link to comment
https://forums.phpfreaks.com/topic/40161-solved-sql-query-sorted-by-3-columns/
Share on other sites

How?

 

I used the A subquery:

 

SELECT * FROM (SELECT * FROM manufacturer_detail INNER JOIN handset_detail ON manufacturer_detail.manufacturer_detail_id=handset_detail.manufacturer_detail_id

INNER JOIN handset_type ON handset_detail.handset_code=handset_type.handset_code $where ORDER BY handset_detail_id DESC LIMIT 150) t1 ORDER BY manufacturer_name, handset_model

 

Works perfectly.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.