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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:50:06+00:00 2026-06-18T09:50:06+00:00

I am currently working on one table, this table holds for example, customer number,

  • 0

I am currently working on one table, this table holds for example, customer number, this customer number is found in two other tables that I want to pull details about this number ( name, phone tec.).
So my query displays only customers that have a match in the query of some CODE Number, this is because i`m using INNER Join.

I want to display rows that don’t have match in the other tables. They are in the table that I select from but don’t have the code number. (like an empty row that I want to display)
The next query will be more understandable

$sql="SELECT $tbl_name.*,customers.fname,eventcodes.DISCODE,eventcodes.AREA
                FROM $tbl_name
                    INNER JOIN customers
                        INNER JOIN eventcodes
                                ON $tbl_name.Ccode=eventcodes.MokedCcode AND eventcodes.Ccode=customers.Ccode  AND $tbl_name.CODE=eventcodes.CODE
                                                                ORDER By `id` DESC
                                                                        LIMIT $start, $limit";

As you can see all the rows I want to display found on $tbl_name, this query work but it display to me only the rows that match the conditions, I want to display all the rows from the table those that don’t have CODE, but I can pull their name for example (fname) from the customers table because I have their code (customer number).
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-06-18T09:50:07+00:00Added an answer on June 18, 2026 at 9:50 am

    Use LEFT JOIN and watch out the join conditions:

    SELECT 
      t.*,
      c.fname,
      e.DISCODE,
      e.AREA
    FROM $tbl_name       AS t
    LEFT JOIN customers  AS c ON t.Ccode = c.Ccode
    LEFT JOIN eventcodes AS e ON t.Ccode = e.MokedCcode 
    ORDER By `id` DESC
    LIMIT $start, $limit";
    

    Note that: I moved the condition customers.Ccode = $tablename.Ccode to the first join, and removed the condition $tbl_name.CODE=eventcodes.CODE, Since the first two joins will insure that condition.

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

Sidebar

Related Questions

My problem is that the website I'm currently working on has two tables for
The database I am working with currently does have two tables, one holding the
I'm currently working on a project with a one page design that'll slide up
I am currently working on a module that takes one of our business objects
I am currently working on a page that has a date picker for one
I am currently working on 2 web servers, One Coldfusion and the other PHP.
In a system I am currently working on, there is one process that loads
I am currently working on a MySQL query that contains a table: TBL:lesson_fee -fee_type_id
I'm currently working through O'Reilly's Programming PHP and have come across this table titled
I am currently working on a pyramid system that uses sqlalchemy. This system will

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.