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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:41:53+00:00 2026-06-17T20:41:53+00:00

Method 1 SELECT o.*, bc.*, s.name AS plan_name, p.image AS course_image, p.id AS course_id,

  • 0

Method 1

SELECT o.*, 
       bc.*, 
       s.name  AS plan_name, 
       p.image AS course_image, 
       p.id    AS course_id, 
       p.name  AS course_name, 
       p.id, 
       p.level 
FROM   wg_guru_order o 
       JOIN wg_guru_buy_courses bc 
         ON o.id = bc.order_id 
       JOIN wg_guru_subplan s 
         ON bc.plan_id = s.id 
       JOIN wg_guru_program p 
         ON bc.course_id = p.id 
WHERE  o.status = 'Paid' 
       AND bc.userid = 451 
        OR p.catid = 26 
           AND p.published = 1

EXPLAIN Command output

enter image description here

Method 2

 SELECT o.*,
       bc.*,
       s.name  AS plan_name,
       p.image AS course_image,
       p.id    AS course_id,
       p.name  AS course_name,
       p.id,
       p.level
FROM   wg_guru_order o,
       wg_guru_buy_courses bc,
       wg_guru_subplan s,
       wg_guru_program p
WHERE  o.status = 'Paid'
       AND o.id = bc.order_id
       AND bc.userid = 451
       AND bc.plan_id = s.id
       AND bc.course_id = p.id
        OR p.catid = 26
           AND p.published = 1 

EXPLAIN Command output

enter image description here

Above two are the same which happens to be working fine for me. Only difference is method 1 query is written using JOIN claues & ON, method 2 is written using JOIN shorthand method.

Problem is method 1 return 3 rows, method 2 return 1543 rows. How can the same query returns different results ?

Given that I just want to understand why is it. I’m not concern about the results set. All I wonder is how can the same query written in two ways outputs different types of result sets?

  • 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-17T20:41:54+00:00Added an answer on June 17, 2026 at 8:41 pm

    Always prefer the first option.

    Both options are standard, but the second option is from the older SQL-89 standard. The first option is the new SQL-92 standard. The older standard is deprecated, and some databases are beginning to follow through on that deprecation. For example, Sql Server 2012 dropped support for doing out outer joins via the old syntax. It’s still fully supported by MySQL, but you shouldn’t really count on it staying that way for the life of your application.

    Going beyond this, those are not the same queries. You need to add some parentheses to the WHERE clause to control how your OR condition is interpreted. This is why the queries return different sets of rows. As written, it’s as if your where clauses look like this:

    Method 1:

    WHERE  (o.status = 'Paid' AND bc.userid = 451)
        OR (p.catid = 26 AND p.published = 1)
    

    Method 2:

    WHERE 
       (o.status = 'Paid'
          AND o.id = bc.order_id
          AND bc.userid = 451
          AND bc.plan_id = s.id
          AND bc.course_id = p.id
       ) OR ( p.catid = 26 AND p.published = 1)
    

    Note the groupings… that’s probably not what you intended. I expect you intended something more like this:

    WHERE  o.status = 'Paid'
      AND  o.id = bc.order_id
      AND  bc.course_id = p.id
      AND  bc.plan_id = s.id
      AND (bc.userid = 451 OR p.catid = 26)
      AND  p.published = 1
    

    Right now neither of your queries works this way, but I think it’s closer to what you were really trying to do. You need the write the query with the parentheses in right places to get the results you want.

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

Sidebar

Related Questions

I was using the Add class method $(select[name=' + ABC+ i + ']).addClass('addBorder'); This
My current method is this: SELECT TOP 1 ID FROM DATAENTRY ORDER BY ID
Is there any method to do this: SELECT * FROM `cores` WHERE superkinds IN
$fql = 'SELECT name from user where uid = ' . $user; $result =
Tried a query first like this SELECT * FROM CUSTOMER WHERE LEFT(NAME, 1) =
(This is called via PHP) I have the following: SELECT name FROM user WHERE
SELECT a.tag,CONCAT(u.first_name,' ',u.last_name) FROM assets a LEFT JOIN (SELECT asset_id,assigned_to_id FROM asset_activity WHERE assigned
SELECT COUNT(organization.ID) FROM organization WHERE name in ( SELECT name FROM organization GROUP BY
I have a fql query: {e426262700718049:SELECT name, start_time, location, creator, pic_square FROM event WHERE
i'm playing with these code and it fails: $fql = SELECT name FROM group

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.