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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:51:53+00:00 2026-06-13T02:51:53+00:00

i have the following query that pulls posts that belong to a blog SELECT

  • 0

i have the following query that pulls posts that belong to a blog

SELECT p.* 
FROM  `Posts` p
INNER JOIN Blogs b ON b.id = p.blog_id

Is there a MySQL function that does the opposite of “ON”? If i wanted to query posts that didn’t belong to a blog in the “Blogs” database table? For instance if the blog was deleted.

  • 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-13T02:51:56+00:00Added an answer on June 13, 2026 at 2:51 am

    It’s all about the JOIN.

    SELECT p.* 
    FROM  `Posts` p
    LEFT OUTER JOIN Blogs b ON b.id = p.blog_id
    
    WHERE b.Id IS NULL
    

    Should do the trick for you.

    Jeff Atwood has a great overview of joins

    In this instance, what the LEFT OUTER JOIN does is match all rows in Blogs with all rows in Posts with the same blog_id-Id combo AND all rows in Posts that have no matching Id in Blogs. In this instance, those rows are NULL for the entries in Blogs (as there aren’t any!), which is why we filter on b.Id IS NULL

    There are some other ways you can achieve this too; for example:

    SELECT * FROM Posts WHERE blog_id NOT IN (SELECT Id FROM Blogs)
    

    Effectively, this queries all rows in posts that have a blog_id that isn’t in the blog table.

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

Sidebar

Related Questions

I have the following query that works well. SELECT DISTINCT city,region1,region2 from static_geo_world where
I have the following query: select * from winners join profiles on winners.subscriber_id =
I have the following query that retrieve the number of users per country; SELECT
I have the following query with many LEFT JOIN clauses that has 7 result
I have the following query SELECT * FROM invoice WHERE invoice_id IN (13, 15,
I have the following jquery Autocomplete form that pulls data in from a local
I have the following zip codes in a linked table. My query pulls from
I have the following query that joins a bunch of tables. I'd like to
I have the following query that executes perfectly in MySQL, but it is giving
I have the following query that I want it to show Not Yet instead

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.