Jump to content

[SOLVED] I need to sort 2 tables...


Salis

Recommended Posts

I'm working on my own forum for my gaming site. I need a lot of integrations and I'd rather make my own forum then mod the heck out of some one else's. I can do all the queries I need expect one. I need 1 query to read the boards then categories. Similar to this site. For an example:

 

Welcome to the =Fire= Squad <- Board 1

    General Chat <- Category 1 of Board 1

    News & Events <- Category 2 of Board 1

 

=Fire= Squad Server <- Board 2

    Dates & Times <- Category 1 of  Board 2

 

This is what I started:

("SELECT * FROM sqd_boards
	LEFT JOIN sqd_categories.ID_Cat
	ON sqd_boards.ID_Board = sqd_categories.ID_Cat
	ORDER BY sqd_boards.Board_Sort ASC")

 

As you can see it sorts the Boards but how can I also sort the Categories as well? Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/61927-solved-i-need-to-sort-2-tables/
Share on other sites

ORDER BY sqd_boards.Board_Sort,sqd_categories.ID_Cat ASC;

 

It all depends the data in the two columns, it works fine as long as we don't have any records that contradicting each other. By default it keeps in ascending order but id doesn't matter even if u explicitly specify that one.

 

It all depends the data in the two columns, it works fine as long as we don't have any records that contradicting each other. By default it keeps in ascending order but id doesn't matter even if u explicitly specify that one.

 

Thanks. There shouldn't be. I'm just reading the board names then the categories. So far this was the only query I needed help on. I never knew you could order 2 tables this way.

 

Thanks for your help Illusion.

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.