self-join Questions

15

Solved

I don't understand the need for self-joins. Can someone please explain them to me? A simple example would be very helpful.
Guernsey asked 16/3, 2010 at 22:7

7

Solved

What is the simplest way of doing a recursive self-join in SQL Server? PersonID | Initials | ParentID 1 CJ NULL 2 EB 1 3 MB 1 4 SW 2 5 YT NULL 6 IS 5 I want to be able to get the records only rela...
Amil asked 18/11, 2009 at 16:29

4

Solved

Does it get any simpler than this query? delete a.* from matches a inner join matches b ON (a.uid = b.matcheduid) Yes, apparently it does... because the performance on the above query is really...
Sosthenna asked 17/8, 2011 at 5:47

3

Solved

I have a component list made of 3 columns: product, component and quantity of component used: a <- structure(list(prodName = c("prod1", "prod1", "prod2", "prod3", "prod3", "int1", "int1", "int...
Paulinepauling asked 30/6, 2019 at 2:39

2

Solved

I have a self-join for my model in ActiveRecord, as follows: class Employee < ActiveRecord::Base has_many :subordinates, class_name: "Employee", foreign_key: "manager_id" belongs_to :manag...
Distil asked 12/8, 2015 at 18:44

6

Solved

I am trying to get some rows from the same table. It's a user table: user has user_id and user_parent_id. I need to get the user_id row and user_parent_id row. I have coded something like this: ...
Shamikashamma asked 10/2, 2013 at 10:24

0

In the project I´m working there is a part of the database that is like the following diagram The domain classes have a definition similar to the following: class File{ String name } class Do...
Oleta asked 10/10, 2017 at 19:14

1

Solved

While preparing an answer to the question dplyr or data.table to calculate time series aggregations in R I noticed that I do get different results depending on whether the table is updated in place...
Denominational asked 21/8, 2017 at 8:47

4

Solved

I have a table: Parent Child Educated 'P1', 'C1', 'YES' 'P1', 'C2', 'YES' 'P1', 'C3', 'NO' 'P2', 'C11', 'YES' 'P2', 'C12', 'NO' 'P3', 'C21', 'YES' 'P3', 'C22', 'YES' 'P4', 'C31', 'NO' 'P4', 'C32',...
Subacute asked 2/8, 2017 at 14:36

1

Solved

I am trying to query in SQL and I can not resolve it. I have a table tCliente: What I want to do is a JOIN with the same table to find each pair of clients that lives in the same city. I try to...
Fellmonger asked 22/1, 2017 at 17:32

6

I've got a table of people - an ID primary key and a name. In my application, people can have 0 or more real-world relationships with other people, so Jack might "work for" Jane and Tom might "repl...
Revert asked 1/5, 2010 at 18:47

2

Solved

What would I seek to achieve from a self-join? I already know what a self-join does. Operational descriptions on Stack Overflow with tables or join lists or the self-referencing employee-manager ex...
Desma asked 1/4, 2016 at 9:9

4

Solved

Here is my testing table data: Testing ID Name Payment_Date Fee Amt 1 BankA 2016-04-01 100 20000 2 BankB 2016-04-02 200 10000 3 BankA 2016-04-03 100 20000 4 BankB 2016-04-04 300 20000 I am try...
Eleanor asked 22/4, 2016 at 1:22

7

Solved

I have the following tables: Employees ------------- ClockNo int CostCentre varchar Department int and Departments ------------- DepartmentCode int CostCentreCode varchar Parent int Departmen...
Cassaundra asked 15/4, 2016 at 12:44

1

Given a table named rating in a MySQL database. +-------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-----...
Ectomorph asked 12/3, 2016 at 19:1

2

I would like to know if i can convert this criteria into a detached criteria. I am not understanding detached criteria correctly. can some one help. Criteria crit = sessionC.createCriteria(OP_DOCT...
Griswold asked 16/2, 2016 at 5:47

6

Suppose I have a table consisting of entries like ID Arrival Date Arrival City Departure Date Departure City 1 Jun 27 2015 Berlin Jun 20 2015 Paris 1 Jul 1 2015 Rome Jun 29 2015 Berlin 1 Jul 30 20...
Mores asked 15/1, 2016 at 16:45

2

I have a page table. Pages can have parents, which are also pages. I want to select all pages with parent_id = NULL and their 'children'. But when I try this public function getPages() { return $...
Matri asked 17/6, 2015 at 19:14

3

Solved

I need to use Self Join on this table. +------------+------+--------+ | Country | Rank | Year | +------------+------+--------+ |France | 55 | 2000 | +------------+------+--------+ |Canada | 30 | 2...
Rockyrococo asked 22/5, 2013 at 21:32

1

I have a table in an oracle database. The schema is create table PERIODS ( ID NUMBER, STARTTIME TIMESTAMP, ENDTIME TIMESTAMP, TYPE VARCHAR2(100) ) I have two different TYPE's: TYPEA and...
Niacin asked 1/8, 2015 at 20:27

3

With a 2-column data.table, I'd like to summarize the pairwise relationships in column 1 by summing the number of shared elements in column 2. In other words, how many shared Y elements does each p...
Allamerican asked 27/2, 2015 at 9:39

1

How would you write a self join in eloquent? Would I need to define the relationship on the model? Here's my statement: SELECT t2.title FROM products t1, products t2 WHERE t1.id = $id AND t2.col...
Hominy asked 2/6, 2015 at 9:53

5

Solved

Consider the following table: mysql> select * from phone_numbers; +-------------+------+-----------+ | number | type | person_id | +-------------+------+-----------+ | 17182225465 | home | 1 | ...
Utilitarianism asked 5/12, 2008 at 15:8

1

Solved

I am trying to do a join of a data.table with itself. The condition to join is based on the value of a column (not the key) being used to access a matrix. Each row has a date(in seconds) and record...
Slaty asked 17/3, 2015 at 13:54

3

Solved

Given the following data.table with financial data: userId systemBankId accountId valueDate quantity description 871 0065 6422 2013-02-28 -52400 AMORTIZACION PRESTAMO 871 0065 6422 2013-03-28 -52...
Arakawa asked 10/3, 2015 at 15:15

© 2022 - 2024 — McMap. All rights reserved.