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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:48:19+00:00 2026-05-29T21:48:19+00:00

I have two tables.. 1st Table: post |post_id | post_data | …………………….. | 1

  • 0

I have two tables..

1st Table: post

|post_id  |    post_data |
..........................
|   1     |    any data  |
|   2     |    any data  |
|   3     |    any data  |

2nd Table: post_likes

|like_id  |    post_id   | by_user |
....................................
|   1     |      1       |   3     |
|   2     |      3       |   3     |

when ever a user like any post data is stored in posts_likes table..
i want to show that posts (from both tables once) that are not liked by user 3..

i am using this query

SELECT *
FROM post, post_likes
WHERE post.post_id != post_likes.post_id
AND by_user=3

it showing me these results..

post_id     post_data   like_id     post_id     by_user
  1         my data       2            3          3
  2         my data       1            1          3
  2         my data       2            3          3
  3         my data       1            1          3

But it should show the result of post_id=2 only (because post_id 1 and 3 are liked by user)

what will be the correct query by which i can get those posts that are not liked by user 3

  • 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-05-29T21:48:20+00:00Added an answer on May 29, 2026 at 9:48 pm

    You can use a NOT IN ()subquery in your WHERE clause:

    SELECT
      posts.post_id,
      posts.post_data,
      post_likes.like_id,
      post_likes.by_user
    FROM posts LEFT JOIN post_likes ON posts.post_id = post_likes.post_id
    WHERE posts.post_id NOT IN (
      SELECT DISTINCT post_id FROM post_likes WHERE by_user = 3
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two DBs. The 1st db has CallsRecords table and 2nd db has
Suppose I have two tables 1st table emp EmpID | EmpName|xyz...coloums 1. | Hrishi
All I have two table 1st table is : wp_frm_item_metas 2nd table is :
I have two databases. I want to dump data from one table in 1st
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have two tables in my database, 1st one contains a couple of sentences,
Have two sets of data (two tables) for patient records, one 1999-2003, the other
I have two tables. One is a table of the reports that have been
High level I have two tables that need to have some of the data
If I have two migration files: 20110414132423_insert_bulk_data.rb #1st 20111122105951_add_some_columns.rb #2nd and I run rake

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.