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 8788221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:06:23+00:00 2026-06-13T22:06:23+00:00

I have two tables, posts and pages . The posts table has more columns

  • 0

I have two tables, posts and pages. The posts table has more columns than the pages table, but other than that they are the same in terms of schema.

If a slug is given, the row with the right slug could exist in the pages table, or the posts table. I was thinking of something like

SELECT * 
FROM pages 
WHERE slug = 'about'

UNION 

SELECT * 
FROM posts 
WHERE slug = 'about'

but that requires the row with the slug of “about” to be in both tables. There’s probably a simple INNER JOIN I could use, but my SQL knowledge is limited.

To clarify, I want to be able to search across both tables as if they were one.

Here is the posts table structure:

`slug` varchar(128) NOT NULL,
`id` varchar(100) NOT NULL,
`title` text NOT NULL,
`published` bigint(20) NOT NULL,
`content` longtext NOT NULL,
`author` text NOT NULL,
`status` enum('published','draft','trashed') NOT NULL

and the pages structure:

`slug` varchar(128) NOT NULL,
`id` varchar(100) NOT NULL,
`title` text NOT NULL,
`content` longtext NOT NULL,
`menu_order` int(11) DEFAULT NULL,
`status` enum('published','drafted','trashed') NOT NULL
  • 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-13T22:06:24+00:00Added an answer on June 13, 2026 at 10:06 pm

    You can use union but you need to specify columns (col1,col2,..) the two list should be identical:

    SELECT col1,col2,.. 
    FROM pages 
    WHERE slug = 'about' 
    
    UNION
    
    SELECT col1,col2,.. 
    FROM posts 
    WHERE slug = 'about'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: mysql is array in multiple columns I have two tables: Posts Table
I have two tables, Pages and Posts that are in HABTM and are joined
I have two tables, blogs and posts, with the expected relationship between them. Posts
I have two tables. Table 1. ======== id post -------- Table 2. ======== id
I have two tables, lets say table1 and table2 with common columns, id and
I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables user table user_id | name | 1 | peter |
I have two tables post Table post_id post_name post_summary date post_reply Table parent_id post_id
I have two tables. Posts and Replies. Think of posts as a blog entry

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.