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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:32:13+00:00 2026-06-03T20:32:13+00:00

My SQL statement looks like that SELECT SQL_CALC_FOUND_ROWS q.id, q.question, sb.subject, c.chapter, sc.section, p.paragraph

  • 0

My SQL statement looks like that

SELECT SQL_CALC_FOUND_ROWS q.id, q.question, sb.subject, c.chapter, sc.section, p.paragraph 
FROM questions AS q
     , subjects AS sb
     , sections AS sc
     , chapters AS c
     , paragraphs AS p 
WHERE (sb.id=q.subject AND c.id=q.chapter AND sc.id=q.section AND p.id=q.paragraph) AND (q.author_id=1) 
ORDER BY  q.id asc 
LIMIT 0, 25

As you see, theese tables related with each other by id. The problem is, I’m getting subject column of questions table instead of subject column of subjects table. What am I missing here?

Note

I provided subject as example. Actually all three sections AS sc, chapters AS c, paragraphs AS p are not working. I’m getting only subject.

  • 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-03T20:32:14+00:00Added an answer on June 3, 2026 at 8:32 pm

    I normally use JOIN syntax explicitly. This will sometimes give you better error output, to help track down the issue.

    Here’s the original, formatted so you can easily see the differences.

    SELECT SQL_CALC_FOUND_ROWS q.id, q.question, sb.subject, c.chapter, sc.section, p.paragraph 
    FROM questions AS q, 
         subjects AS sb, 
         sections AS sc, 
         chapters AS c, 
         paragraphs AS p 
    WHERE (sb.id=q.subject 
           AND c.id=q.chapter 
           AND sc.id=q.section 
           AND p.id=q.paragraph) 
          AND (q.author_id=1) 
    ORDER BY  q.id asc 
    LIMIT 0, 25
    

    And here’s the edited version – notice the WHERE clause parameters that define how the tables hook together have been moved up to the table names list as ON clauses. This is part of the INNER JOIN syntax, which is: INNER JOIN ON .

    SELECT SQL_CALC_FOUND_ROWS q.id, q.question, sb.subject, c.chapter, sc.section, p.paragraph 
    FROM questions AS q
      INNER JOIN subjects AS sb ON sb.id = q.subject
      INNER JOIN sections AS sc ON sc.id = q.section 
      INNER JOIN chapters AS c ON c.id = q.chapter
      INNER JOIN paragraphs AS p ON p.id = q.paragraph
    WHERE (q.author_id=1) 
    ORDER BY  q.id asc 
    LIMIT 0, 25
    

    If you try to run that against MySQL directly, what happens?

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

Sidebar

Related Questions

I have an SQL statement that looks something like: SELECT * FROM table1 AS
I have a SQL statement that looks like: SELECT [Phone] FROM [Table] WHERE (
So I've got a SQL statement that pared down looks something like this: SELECT
i am new to access sql and i built a select statement that looks
I'm trying to create sql statement in TSQL that looks like this: INSERT INTO
I have LINQ statement that looks like this: return ( from c in customers
I've got a SQL statement in SQL Server 2005 that looks something like this:
So I have an SQL statement looks like this SELECT T1.NAME, COUNT(T2.VALUE) AS numInstances
I have a SQL Statement that works as I want. select COUNT(*), MIN(emailed_to)from email.email_archive
I have a table with 53 rows. My sql statement looks like this: SELECT

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.