Questions tagged [inner-join]

A database operation that combines the values of 2 tables based on a condition, or relationship, that exists between those tables.

An inner join is the most common join operation used in applications and can be regarded as the default join-type. Inner join creates a new result table by combining column values of two tables (A and B) based upon the join-predicate. The query compares each row of A with each row of B to find all pairs of rows which satisfy the join-predicate.

When the join-predicate is satisfied, column values for each matched pair of rows of A and B are combined into a result row. The result of the join can be defined as the outcome of first taking the Cartesian product (or Cross join) of all records in the tables (combining every record in table A with every record in table B) then returning all records which satisfy the join predicate.

Actual SQL implementations normally use other approaches like a hash join or a sort-merge join where possible, since computing the Cartesian product is very inefficient.

enter image description here


Resources :

6652 questions
1
vote
0 answers

Proper Term to Describe Output from Inner Join

Just keeping it simple here, so this is not specific to any computer language. But suppose I'm joining 2 tables, A and B. The relationship between the 2 tables is 1:many. If I use some type of code that performs an inner join between A and B, the…
KristiP
  • 11
  • 3
1
vote
1 answer

Conditional INNER JOIN or LEFT JOIN based on the joining condition

I have a query SELECT users.email AS email, addons.sku AS sku, addons.quantity as quantity, invoices.total as total FROM addons INNER JOIN users ON 1=1 and users.id = addons.user_id LEFT JOIN invoices ON 1=1 AND invoices.user_id =…
Almazik G
  • 1,066
  • 1
  • 9
  • 21
1
vote
2 answers

Update inner join result Oracle

In my java code I have foreach loop which iterates though list foreach(MyObject obj:list){ String status = obj.getStatus(); String is = obj.getId(); // DB call 1. To update Status in Table A …
hemantmali
  • 63
  • 2
  • 13
1
vote
2 answers

How to JOIN Four tables, with muliple constraints

I have to write a SQL statement to show a sum for similar types, I also need add another exclusion constraint from another table. This is using Microsoft Access 2010. The problem reads: Write an SQL statement to show the sum of HoursWorked for…
1
vote
2 answers

SQL select dependent on count with condition

I have two tables: Table A: Table B: id name id a_id param 1 xxx 1 1 3 2 yyy 2 1 4 3 1 5 4 2 3 …
Sergey Dylda
  • 399
  • 3
  • 12
1
vote
1 answer

Sql server - Inner Join syntax with two joins

I've noticed one of our programmers wrote this: SELECT * FROM Table_A A INNER JOIN Table_B B INNER JOIN Table_C C ON C.Id = B.Id ON B.Id = A.Id I didn't expect this to work but it does return results from our database. Does this…
Carra
  • 17,808
  • 7
  • 62
  • 75
1
vote
2 answers

How to do SQL Join with many tables (FK tables have looped results sharing ID)

I am newish to SQL and Join statements and I am way out of my league at the moment I currently have 6 Database Tables that are all linked to the main 7th table based on the main tables ID, however all the information in the other 6 tables are looped…
Meitie
  • 75
  • 1
  • 8
1
vote
0 answers

SAP HANA | JOIN with LIKE OPERATOR

I have two tables - TABLE T1 having below data - COL1 COL2 1 A,B,C TABLE T2 having below data - COL3 COL4 A 10 B 20 C 30 D 40 The output I want is - COL1 COL3 COL4 1 A …
Anirudh D
  • 181
  • 3
  • 14
  • 33
1
vote
1 answer

Select Inner join and update in single query

I want to find ranking and then update their rank column according to their id. My data is as follows (Table Member). MEMBER_ID | LOAN_AMOUNT | Rank 1 | 2,000.00 | 0 2 | 1,000.00 | 0 3 | 4,000.00 | 0 4 |…
Anik Saha
  • 4,313
  • 2
  • 26
  • 41
1
vote
2 answers

INNER JOIN with Condition - Mysql

I'm trying to make an inner join if a condition is true but it does not work, I've tried these 2 ways: IF chat.tipo = 'vitima' THEN INNER JOIN vitima ON vitima.id_vit = chat.id_tipo ELSE INNER JOIN terceiro ON terceiro.id_ter =…
Woton Sampaio
  • 469
  • 6
  • 24
1
vote
1 answer

Need help understanding unexpected behavior using LINQ Join with HashSet

I encountered some odd behavior using C# HastSet with LINQ's Join method that I don't understand. I've simplified what I am doing to help focus on the behavior I am seeing. I have the following: private HashSet _mySet; // module level …
RB Davidson
  • 528
  • 6
  • 17
1
vote
2 answers

Get foregin key value not id SQL

guys php beginner is here :) i know my question has been asked a lot, but i read more than 20 answers & most of them not working with my query, and my query is simple but i don't know why didn't work with me :(, i have 2 TABLE : 1- USERS :…
Romer
  • 30
  • 9
1
vote
1 answer

Inner join two table variables and return an output cursor from an anonymous plsql block in a c# application

I have this scenario: I need to insert the result of many joins (15 tables with various filters) into a table variable var_TB_PROJECT Then insert the result of many other joins (8 tables with various filters) into another table variable…
Goldar
  • 61
  • 1
  • 6
1
vote
1 answer

SQLite Execute query from joined Tables

I am struggling with my final project. I need to join 2 Tables "book" and "idlist" and execute the values in index.html. Here is python and html code (also idlist Tablebook Table). If someone knows where is a mistake, I will be…
1
vote
2 answers

Avoid multiple SELECT while updating a table's column relatively to another table's one

I am quite a newbie with SQL queries but I need to modify a column of a table relatively to the column of another table. For now I have the following query working: UPDATE table1 SET date1=( SELECT last_day(max(date2))+1 FROM table2 …
Julien Camus
  • 43
  • 1
  • 4
1 2 3
99
100