It looks as if you need an outer join, I’ll use a left one in my example:
select t1.Product, t1.Quantity, t2.Cost from table1 as t1 left outer join table2 as t2 on t1.Product = t2.Product
You can also leave out the outer keyword:
select t1.Product, t1.Quantity, t2.Cost from table1 as t1 left join table2 as t2 on t1.Product = t2.Product
Related Posts:
- What is the difference between “INNER JOIN” and “OUTER JOIN”?
- What is the difference between “INNER JOIN” and “OUTER JOIN”?
- SQL Inner-join with 3 tables?
- What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL JOIN? [duplicate]
- How can I do a FULL OUTER JOIN in MySQL?
- SQL update from one Table to another based on a ID match
- “Not unique table/alias” in MySQL
- Difference between JOIN and INNER JOIN
- What is the difference between JOIN and UNION?
- MySQL Multiple Joins in one query?
- SQL join on multiple columns in same tables
- 1052: Column ‘id’ in field list is ambiguous
- 1052: Column ‘id’ in field list is ambiguous
- Join vs. sub-query
- How to create Temp table with SELECT * INTO tempTable FROM CTE Query
- T-SQL split string
- Using group by on multiple columns
- Efficiently convert rows to columns in sql server
- Conversion of a varchar data type to a datetime data type resulted in an out-of-range value in SQL query
- How to split the name string in mysql?
- SQL – HAVING vs. WHERE
- How to SUM two fields within an SQL query
- DateTime2 vs DateTime in SQL Server
- Difference between numeric, float and decimal in SQL Server
- CREATE TABLE IF NOT EXISTS equivalent in SQL Server
- How can I do ‘insert if not exists’ in MySQL?
- “ORA-01438: value larger than specified precision allowed for this column” when inserting 3
- How to join on multiple columns in Pyspark?
- How can I prevent SQL injection in PHP?
- How can I do ‘insert if not exists’ in MySQL?
- Cast from VARCHAR to INT – MySQL
- Conversion failed when converting the varchar value ‘simple, ‘ to data type int
- How to round down to nearest integer in MySQL?
- How do I reset a sequence in Oracle?
- MySQL error: key specification without a key length
- SQL: Two select statements in one query
- What does Include() do in LINQ?
- SQL Server “cannot perform an aggregate function on an expression containing an aggregate or a subquery”, but Sybase can
- How exactly do lookup tables work and how to implement them?
- Get everything after and before certain character in SQL Server
- SQLite string contains other string query
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- Sharing database for collaborative development
- “#1067 – Invalid default value for ‘post_date'” when trying to reset AI after backup
- How to display multiple Post meta_key/meta_values by SQL query
- Inserting Post Meta From SQL
- Updating WooCommerce variable product stock issue
- How to delete users with no order history through phpmyadmin sql?
- SQL to update custom post taxonomies
- Moving an entire wordpress site from one domain to a new domain and database
- WordPress SQL LIKE request doesn’t work for fields with special symbols
- Advanced WP Query hogs the SQL server
- Edit post_content on posts with Featured Image
- Export / import WordPress database
- Sorting events by descending date, and ascending time if multiple events on a date
- WordPress Database Huge wp_usermeta Table
- Genesis framework comments broken?
- WordPress Custom post query sorting does not work
- Get all child comments ids from parent comment id
- I can’t figure out what’s wrong with this statement. $wpdb->query update
- SQL command to convert all tags in lowercase?
- Insert Query not working in the form
- Is it best to avoid using $wpdb for security issues?
- SQL Command for restoring trashed comments
- SQL Bulk update all WordPress user’s nicknames to firstname + lastname format
- Correct PHP to output a single result of a Function with SQL Query
- How can I add a new row in a separate database when someone registers via WordPress?
- Clear Terms from Taxonomy for Specific Post IDs?
- WordPress can I manually add columns in users table and display it in the default manage user plugin and registration form? [closed]
- wordpress site – using custom database and PHP
- wpdb query not working
- $wpdb->get_var – What value is returned when zero records are found?
- How to avoid filling up an array each time I run a WP_query?
- How to SQL query posts IDs by categories AND authors?
- WordPress SQL – How to Check for Category?
- SQL Bulk Move old posts by one author to another category
- SQL query to get posts from multiple categories but not in a category
- Fetching review value using wpdb class
- Why is my insert row only inserting the final row from the loop into the database rather than just inserting one
- add role on WordPress in PHP on a second database
- What is the equivalent WP_Query of a SQL Query?
- Woocommerce change the price of products in the database
- A query to substitute images paths in gutenberg (website migration)?
- Running a PHP SQL script on a wordpress page
- How to speed up “My Account > Orders Page” on Site with More than 200,000 orders?
- Can I replace the “Upgrade Network” with SQL query?
- Inserting other fields to existing registration form in a WordPress theme
- Organising and completing posts (mark as read and hide)
- What argument does my function need to echo get_results() query results
- can’t delete a row from post_meta table
- wpdb->update update the entire table instead of one row
- Sum of Custom Meta written by Authour
- Alter the main search query to search posts by coauthor user name
- SQL error on restoring database
- Help with SQL query, how to add taxonomie terms with value stored in options?
- Convert all dates in field to Unix time, except those already in Unix time
- Wpdb generates too many queries
- Install WordPress with SQL database
- How to update WordPress custom SQL Select query for custom taxonomies so that syntax is correct?
- If meta_key exists then don’t select this post?