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

  • Home
  • SEARCH
  • 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 9213553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:46:31+00:00 2026-06-18T01:46:31+00:00

Here is the query i am using to join two tables SELECT `rf_popup`.* FROM

  • 0

Here is the query i am using to join two tables

SELECT `rf_popup`.* 
  FROM `rf_popup` LEFT JOIN 
       `g_metadata` ON (`rf_popup`.`name` = `g_metadata`.`name`) 
 WHERE (`g_metadata`.`g_id` = '2009112305475443' AND 
        `g_metadata`.`value` < rf_popup.cardinality OR 
        `g_metadata`.`g_id` IS NULL) AND 
       `category` IN ('S', 'all') AND 
       `field` IN ('descr', 'all') AND 
       `filler_type` IN ('F2', 'all') 
 ORDER BY `rf_popup`.`priority` DESC LIMIT 5 

THIS IS TABLE rf_popup

+--------------+------------------------------------------------------------------------------------+------+-----+---------+----------------+
| Field        | Type                                                                               | Null | Key | Default | Extra          |
+--------------+------------------------------------------------------------------------------------+------+-----+---------+----------------+
| id           | int(11)                                                                            | NO   | PRI | NULL    | auto_increment |
| name         | varchar(200)                                                                       | YES  |     | NULL    |                |
| text         | text                                                                               | YES  |     | NULL    |                |
| cardinality  | int(11)                                                                            | NO   |     | 1       |                |
| field        | varchar(200)                                                                       | YES  |     | NULL    |                |
| category     | enum('A','H','N','R','S','D','all') | YES  |     | NULL    |                |
| time_to_show | enum('START','END')                                                                | YES  |     | START   |                |
| filler_type  | enum('F1','F2','F3','R1','R2','R3','all')   | YES  |     | FILLER1 |                |
| priority     | int(11)                                                                            | NO   |     | 0       |                |
+--------------+------------------------------------------------------------------------

————+——+—–+———+—————-+

This is TABLE g_metadata

+-------+--------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| g_id  | varchar(50)  | YES  | MUL | NULL    |                |
| name  | varchar(50)  | YES  | MUL | NULL    |                |
| value | varchar(200) | YES  |     | NULL    |                |
| id    | int(11)      | NO   | PRI | NULL    | auto_increment |
+-------+--------------+------+-----+---------+----------------+

But the Query Returns Empty Result.but if i replace WHERE in query with AND. The query returns the results.Whats the difference??
There shouldn’t be any difference so i am confused

  • 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-18T01:46:32+00:00Added an answer on June 18, 2026 at 1:46 am

    Simply speaking, WHERE filters the entire result set and JOIN ... ON filters only the joined table.

    Since you have a LEFT JOIN here, putting the filter in the ON clause restricts the results returned for the g_metadata table, but does not effect the results returned for rf_popup. That is, you will get null columns in the joined table (g_metadata) but the rows for rf_popup will still be pulled.

    On the other hand, putting the filter in the WHERE clause performs the join first, then filters the resulting (joined) result set. That is, rows that do not match the entire WHEREclause are simply not returned.


    Consider the following simplified examples:

    TableA:
    
    id
    -----
    1
    2
    3
    
    TableB:
    
    id   | yesNo
    -----+------
    1    | yes
    2    | no
    3    | yes
    
    1. A simple join:

      SELECT * 
      FROM TableA 
      LEFT JOIN TableB ON TableA.id = TableB.id
      

      returns

      A.id | B.id | yesNo
      -----+------+------
      1    | 1    | yes
      2    | 2    | no
      3    | 3    | yes
      
    2. Filtering in the ON clause:

      SELECT * 
      FROM TableA 
      LEFT JOIN TableB ON TableA.id = TableB.id
          AND yesNo = 'yes'
      

      returns

      A.id | B.id | yesNo
      -----+------+------
      1    | 1    | yes
      2    | NULL | NULL
      3    | 3    | yes
      
    3. Filtering in the WHERE clause:

      SELECT * 
      FROM TableA 
      LEFT JOIN TableB ON TableA.id = TableB.id
      WHERE yesNo = 'yes'
      

      returns

      A.id | B.id | yesNo
      -----+------+------
      1    | 1    | yes
      3    | 3    | yes
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query pulling data from three tables using LEFT OUTER JOIN for
SELECT gameratingstblx245v.gameid,avg( gameratingstblx245v.rating ) as avgrating, count(gameratingstblx245v.rating) as count,gamedata.name ,gamedata.gameinfo FROM gameratingstblx245v LEFT JOIN
i have a MySQL SELECT query which fetches data from 6 tables using Mysql
I am trying to join two tables like this... SELECT * FROM lists l
im joining and retrieving values from two tables using the below query. It displays
I have joined two tables using inner join. Here primary key of table TPREG
I'm trying to preform a SELECT query that grabs data from two tables only
Here's my query SELECT * FROM wp_postmeta WHERE meta_value LIKE '.$_POST['username'].' AND meta_value LIKE
Here is original Query :, it generates o/p with two columns name (label, count)
Here is my query Select Gender from Table The result pane shows 1 1

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.