Questions tagged [outer-join]

An outer join defines a relationship between two tables where all records from one or both tables are returned regardless of the existence of a matching key-field in the other table. A full outer join combines the results of both tables. A left or right join returns all the records from the first or second specified table, respectively. NULLS are filled in for matches on either side. A self-join compares a table to a copy of itself.

A full combines the results of both tables. A left or right returns all the records from the first or second specified table, respectively. NULLS are filled in for matches on either side. A compares a table to a copy of itself.

References

1671 questions
0
votes
1 answer

LEFT OUTER JOIN, filtered by date

I want to query this: select the contracts that are: - active, - with start_date BEFORE now, - with end_date AFTER now, AND, - that have NO matched record from rents. Note that Rent.month is a date data-type column, with "yyyy-mm-dd" content…
yossi
  • 3,090
  • 7
  • 45
  • 65
0
votes
1 answer

Left Outer Join with CONDITIONAL

I've done a good bit of research on how to do this and was not able to find anything. I don't think what I'm trying to do is too difficult, but I'm not sure where to go from here and wanted to post this question. I have two tables, one (DEVICE) is a…
ossys
  • 4,157
  • 5
  • 32
  • 35
0
votes
1 answer

Join tables with all tuples from table 1, but only 1 matching tuple from table 2

I have two tables that I want to join in MySQL. The first is a table of catalog items - each item has an item_id field. I also have a table of images that are associated with the items (item_id, image_id, content). How can I join these two tables,…
0
votes
1 answer

SQL Server Express 2008r2-sp2 outer join based on 3 common fields: issues with duplicating common fields and FLOAT->NVARCHAR conversion

I have a question about joining data from two permanent tables in the same SQL Server Express 2008-r2 sp2 database into a third permanent table in the same database. Rows in tables need to be joined on a condition if data in three fields common to…
0
votes
1 answer

Trouble with LEFT OUTER JOIN

I'm trying to get a list of products order by the amount sold and by date. I also want to display the products that haven't been sold in the list so I tried doing a subquery first but MYSQL is giving me this message: Operand should contain 1…
bmacuer
  • 37
  • 6
0
votes
2 answers

left join two separate queries

I have two separate queries which pretty much return the same thing: select id from t where id<>'' GROUP BY id having count(*) >= 2; select id from t2 where id is not null GROUP BY id having count(*) >= 2 ORDER BY id ASC; a list of ids…
Eddie Martinez
  • 13,582
  • 13
  • 81
  • 106
0
votes
1 answer

Outer join with Linq causing "GroupJoin" error

The following join projection is throwing the error, "The 'GroupJoin' operation must be followed by a 'SelectMany' operation where the collection selector is invoking the 'DefaultIfEmpty' method." I've run over a few permutations of changes, but…
TheHolyTerrah
  • 2,859
  • 3
  • 43
  • 50
0
votes
2 answers

Convert SQL query (with outer join and datediff) to LINQ

I have this SQL query that needs to be converted to LINQ.I am new to LINQ and the outer join makes it more difficult for me to convert this query into LINQ. select distinct ls.crew, sd.ambulance, case_number from log_sheet ls left outer join…
user1550951
  • 369
  • 2
  • 9
  • 26
0
votes
1 answer

Ambiguous outer join when Left join two tables but duplicate records when link all three

I have three tables: Table1 - Customer profile customer id customer name customer country customer total sales Table2 - Contract list contract number customer id customer state contract sales business code Table3 - Business index business…
0
votes
1 answer

Which Join do I need to use?

Problem: There are 2 tables that I know I need to use. I need to find books, magazines, flyers that have the word "sport" in the title. Example Table Library1: books, magazines etc,... title Example Table Library2: flyers, etc (THIS TABLE DOES NOT…
the hank
  • 15
  • 5
0
votes
1 answer

From Oracle to Postgres

We tried to migrate from Oracle to Postgres. We use ora2pg , but we have an error with this code: SELECT DISTINCT UPU.USUA_C_USUARIO FROM GN_USUARIOS U,TR_USUARIOS_X_PERFILES_USUARIO UPU,TR_V_PERFILES_USUARIOS PU WHERE (U.C_USUARIO =…
Luallo
  • 1
0
votes
1 answer

how to index a one way relation table?

I'm not a DB guy so this may be a trivial question... Suppose 1) i have a relation table (I think that's what it's called), student_class, which holds a student_id and a class_id, (representing a many-to-many between a student table and a class…
inor
  • 2,781
  • 2
  • 32
  • 42
0
votes
1 answer

openJPA outer join on optional many-to-one when have order by clause

I have a scenario, that I would like the generated SQL always using Outer Join for optional ManyToOne. I am using OpenJPA 2.2.1.x. Two entities: Event and Rule, Event have an optional ManyToOne unidirectional relationship to Rule. Following are…
David L
  • 1
  • 2
0
votes
2 answers

OUTER JOIN and FULL OUTER JOIN simplest implementations?

Suspect but not sure: Is a simple list of tables in FROM-clause is a full join by definition? SELECT * FROM table1, table2 and is the case where we are joining tables on condition of not equal parameters is an implementation of the full outer…
Nik Terentyev
  • 2,270
  • 3
  • 16
  • 23
0
votes
7 answers

SQL server query joins

Goal - List average salary for men and average salary for women for each department. Show department name and number. select AVG(salary) as 'Avg salary for men' From [Enterprise].[dbo].[Employee]JOIN [Enterprise].[dbo].[Department] ON…