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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:23:07+00:00 2026-05-20T07:23:07+00:00

Hi im having trouble with this sql. Basically it displays statuses that my friends

  • 0

Hi im having trouble with this sql. Basically it displays statuses that my friends posted, and it filters out the friends that i blocked.

The sql is slooooowwwwwww though.. It takes 2 seconds to process it. What seems to be the problem. (ive listed the tables and some examples of how it looks below the sql) thanks in advance!
The sql….

SELECT from_user_id,content,wall.date, wall.wall_type, users.id, users.displayname 
            FROM wall

            INNER JOIN friendship ON ( wall.from_user_id =friendship.user_a OR wall.from_user_id = friendship.user_b ) 
            INNER JOIN users ON (wall.from_user_id = users.id)WHERE users.id not in (select blocked_id from blocklist where user_id = 1) and (wall.wall_type = 'home' OR wall.wall_type = 'profile' or wall.wall_type = 'topro') AND (
                  (friendship.user_a = 1 and friendship.user_b = wall.from_user_id)
                or  
                    (friendship.user_a = wall.from_user_id and friendship.user_b = 1)    or (wall.user_id_of_wall = 1 or type_id = 1 or from_user_id = 1))GROUP BY wall_id ORDER BY date DESC LIMIT 10 

(table name: blocklist)

    user_id | blocked_id
        1     74
        1     70
        1     94
        1     81

(table name:friendhip)

user_a   user_b status  date
1        93         1   1297323354
1        79         1   1297323409
1        81         1   1297323403
1        82         1   1297323398
1        85         1   1297323389
1        90         1   1297323367
1        89         1   1297323373

(table name:users)

       id   displayname
        1   Kenny  Jack
        8   Wale Robinson
        7   Victor WIlliams
        6   Micheal Harris
        9   Micheal Boston
        10  Yestor Smith

the wall table

wall_id wall_type   user_id_of_wall   type_id   from_user_id    content      viewed   date
   5    profile        8                    8          8         Just chilling! 0   1296858001

THANKS!!!

  • 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-20T07:23:08+00:00Added an answer on May 20, 2026 at 7:23 am

    NOT IN is used for fixed values, use NOT EXISTS instead :

    SELECT from_user_id,content,wall.date, wall.wall_type, users.id, users.displayname 
                FROM wall
    
                INNER JOIN friendship ON ( wall.from_user_id =friendship.user_a OR wall.from_user_id = friendship.user_b ) 
                INNER JOIN users ON (wall.from_user_id = users.id)
    WHERE not exists (select * from blocklist where users.id = blocked_id AND user_id = 1) and wall.wall_type IN ('home', 'profile', 'topro') AND (
                      (friendship.user_a = 1 and friendship.user_b = wall.from_user_id)
                    or  
                        (friendship.user_a = wall.from_user_id and friendship.user_b = 1)    or (wall.user_id_of_wall = 1 or type_id = 1 or from_user_id = 1))
    GROUP BY wall_id
    ORDER BY date DESC LIMIT 10 
    

    [EDIT] Use IN for fixed values (wall_type)…

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

Sidebar

Related Questions

I'm having trouble figuring this out. I stopped ALL of local SQL Services, e.g.
I am having trouble with the following SQL statement. I have had this issue
I'm having trouble figuring this out. If I have a checkboxlist inside a usercontrol,
I'm having trouble trying to define the SQL query for this table: There's a
I'm having trouble with using an IF statement within this sql-server query. What I
I'm using SQL Server MS. I'm having trouble writing this script: CREATE VIEW rental_view
I'm having some trouble figuring out the best way to do this, and I
I'm having trouble getting a Linq to Sql query to work. Basically, I want
I am having trouble figuring out how to coalesce or pivot on a SQL
I'm having some trouble with getting this SQL right. There is a one-to-many relationship

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.