Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7840939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:58:29+00:00 2026-06-02T15:58:29+00:00

ive never done a join like this before basically, i have 2 tables with

  • 0

ive never done a join like this before

basically, i have 2 tables with the following structures:

categories:
- id - int
- name - varchar
- show_in_menu - varchar
- sort_order - int

pages:
- id - int
- name - varchar
- show_in_menu - varchar
- sort_order - int

im trying to write a query that will select all categories and pages and spit them out in a list so that they are ordered by the sort_order field, and i only want to select the rows where show_in_menu == ‘Yes’. the problem is i want this to be ordered by sort_order within both tables, example:

page 1 - (sort order of 0)
page 2 - (sort order of 1)
category 1 - (sort order of 2)
page 4 - (sort order of 3)
category 7 - (sort order of 4)

i really have no clue how to finish my query, here it is:

select c.*, p.* 
from `categories` as c
join `pages` as p

any help would be greatly appreciated…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:58:31+00:00Added an answer on June 2, 2026 at 3:58 pm

    You could try a Union query:

    SELECT * FROM categories
    WHERE show_in_menu = 'Yes'
    UNION
    SELECT * FROM pages
    WHERE show_in_menu = 'Yes'
    ORDER BY sort_order
    

    http://w3schools.com/sql/sql_union.asp

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've never done this before, so im lost here. I have the following transactions
I've never done this before. The website I have just built is the second
Ive never heard of this before, and I have been coding in PHP for
am I going about this in the correct way? Ive never done anything like
I've never done this before, but basically I'm trying to break a large string
Heya guys, now ive never done this method before and i just tried it
I've never done this before, and I'm kind of stumped as to how I
I have no clue of where to start on this. I've never done any
I guess this question of mine is pretty basic but since Ive never done
I've never done anything like this, so I'm not really sure what kind of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.