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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:17:49+00:00 2026-06-13T05:17:49+00:00

I have a MySQL query that is baffling me. I am trying to grab

  • 0

I have a MySQL query that is baffling me. I am trying to grab specific pieces of information from two different tables (blurbs and users), while restricting it to only people who are following.

I have the following query:

SELECT DISTINCT blurbs.text, blurbs.timestamp, users.name, 
     users.username, users.profilepic, users.id 
FROM blurbs,users 
LEFT OUTER JOIN follows 
ON blurbs.uid = follows.following AND follows.follower = ? 
WHERE (blurbs.uid = $user_id OR follows.following IS NOT NULL) 
     AND (LOWER(blurbs.text) LIKE '%$query%' OR LOWER(users.name) LIKE '%$query%') 
     AND blurbs.is_private=0 AND blurbs.uid=users.id 
LIMIT 0,30

It’s not working properly, but I am getting overly confused because of the joins.

What should I do to remedy this?

  • 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-13T05:17:51+00:00Added an answer on June 13, 2026 at 5:17 am

    Try using all the join condition through where clause only e.g.

          select a.*, b.*     //<-- Selectign data from first two tables
          from table1 a, table2 b, table1 c
           where a.id = b.id         //<-- joining condition for first two tables
           and a.xxx= c.yyyyy        //some relation with third table
           and c.aaa =....           //filter conditions using third table
           and c.bbb =...            //filter conditions using third table
    

    Trying to rephrase your query as below:

       SELECT DISTINCT blurbs.text, blurbs.timestamp, users.name, 
           users.username, users.profilepic, users.id 
       FROM blurbs,users, follows
       WHERE blurbs.uid=users.id
         AND blurbs.uid = follows.following 
         AND follows.follower = ?
         AND (blurbs.uid = $user_id OR follows.following IS NOT NULL) 
         AND (LOWER(blurbs.text) LIKE '%$query%' OR LOWER(users.name) LIKE '%$query%') 
         AND blurbs.is_private=0
       LIMIT 0,30
    

    Having done this, I hope you can better control/manage the desired filter conditions.

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

Sidebar

Related Questions

I have a MySQL query that: gets data from three tables linked by unique
I have a mysql query that is trying to combine the following tables: TABLE:
I have a MySQL query that uses two different timestamps that can be perceived
I have a MySQL query that selects data from multiple tables and then orders
I have a complex MySQL query that joins three tables and self-joins one table
I have a MySQL query that is trying to get all the Pages that
I have a MySQL query that fetches a numeric value VARCHAR (20) from a
I have a MySQL query that is copying data from one table to another
I have the following MySQL query that I'm trying to translate into an equivalent
I have a simple MySQL query that selects all columns from the table based

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.