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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:44:06+00:00 2026-05-27T09:44:06+00:00

I am trying to join two tables like this… SELECT * FROM lists l

  • 0

I am trying to join two tables like this…

SELECT * FROM lists l
INNER JOIN products p USING (list_id)

Here is the show create table for both the tables..

CREATE TABLE `lists` (
  `list_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `list_name` varchar(255) NOT NULL,
  `deleted` tinyint(4) NOT NULL DEFAULT '0'
  PRIMARY KEY (`list_id`),
  KEY `index1` (`list_name`),
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8

CREATE TABLE `products` (
  `product_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `list_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `deleted` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`product_id`),
  KEY `index2` (`deleted`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8

Here’s the result of above query:

l.list_id : l.list_name : l.deleted : p.product_id : p.deleted

1   Christmas   0   1   1
1   Christmas   0   2   0
1   Christmas   0   3   0
1   Christmas   0   4   0
4   New Year    0   8   0
4   New Year    0   9   0
4   New Year    0   10  0

You see l.deleted column there with all zeros? In the table lists there are some rows with other values like 1, 2, … in deleted column. But joining the tables always show the deleted column to have all zeros.

Why is this happening? What am I missing here?

  • 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-05-27T09:44:07+00:00Added an answer on May 27, 2026 at 9:44 am

    I suggest you use a different syntax to express your JOIN. If you use the ON syntax, you’ll have more clarity about what is joining to what. This is stylistic.

    Try this:

    SELECT * FROM lists l
    INNER JOIN products p ON l.list_id = p.list_id
    

    But, I suspect you have items in your lists table (with deleted column values that aren’t zero, that aren’t turning up in your products table. To see those in your result set try this:

    SELECT * FROM lists l
    LEFT JOIN products p ON l.list_id = p.list_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using extension syntax I'm trying to create a left-join using LINQ on two lists
I'm trying to force Linq to preform an inner join between two tables. I'll
I am trying to join two tables; the purpose being able to search and
I'm trying to LEFT JOIN two tables, to get a list of all rows
I'm trying to use natural join to join two tables in mySQL that have
I'm trying to write a LINQ expression that will join two tables and return
I am using Access 2007 to create an SQL query to join two tables.
I'm trying to perform a select query over two tables, one containing, for example,
In SQL Server, I am trying to get the rows from the two tables
I'm trying to join two tables: Rooms and Room_Types (which have a relationship already).

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.