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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:49:15+00:00 2026-06-16T08:49:15+00:00

I have two tables like so subscribers id subscriber subscribe_to 1 user1 user2 2

  • 0

I have two tables like so

subscribers

id    subscriber     subscribe_to
1       user1          user2
2       user2          user3
3       user1          user2
4       user3          user4
5       user1          user2
6       user1          user7
7       user5          user2
8       user8          user9
9       user1          user10

And my other table like so:
main

id    by_user      post_name
1     user1        somename1
2     user2        somename2
3     user1        somename3
4     user3        somename4
5     user3        somename5
6     user1        somename6
7     user2        somename7
8     user3        somename8

I want to use php-mysql to get all the subscriptions of user1 (for example) from table 1. And then pull the common name from table 2 but I am not sure how to fetch the second table

$get_subscriptions = mysql_query("SELECT * FROM `subscribers` WHERE `subscriber` = 'user1'");
if(mysql_num_rows($get_subscriptions) == 1){
$fetch = mysql_fetch_assoc($get_subscriptions);
$subscriptions = $fetch['subscribe_to'];//this will return an array with all the subscribed to users by user1
} 

Now, I want to fetch the second table and get all the post_name (from $subscriptions). I am not sure how to write the query.

$get_posts= mysql_query("SELECT * FROM `main` WHERE....");
  • 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-16T08:49:16+00:00Added an answer on June 16, 2026 at 8:49 am

    Try this:

    SELECT post_name FROM main 
    WHERE by_user = 'user1' OR by_user IN (SELECT subscribe_to FROM subscribers WHERE subscriber = 'user1')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given my two db tables aliases and subscriber have entries like this: aliases.username =
I have two MySQL tables like this: User Id (PK, auto-increment integer) Subscriber Id
I have two tables like so; id_image foo bar 1 3 5 2 8
I have two tables like, CREATE TABLE [dbo].[entry] ( [id] [int] NULL, [service] [int]
I have two tables like the ones below. I need to find what exchangeRate
I have two tables like of this structure: content (content_id, content_type, user_id, time, comment_count)
So I have two tables structured like so: CREATE TABLE #nodes(node int NOT NULL);
I'm using SQL Server 2008. Let's say I have two hypothetical tables like below:
I have two MySQL tables something like this: tool_owners: tool_owners_id | user_id | ...
Let's say I have two tables that look like this: TH TH TH TH

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.