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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.