tagged [join]
Join/Where with LINQ and Lambda
Join/Where with LINQ and Lambda I'm having trouble with a query written in LINQ and Lambda. So far, I'm getting a lot of errors here's my code: ``` int id = 1; var query = database.Posts.Join(database...
T-SQL: Inner join on a field with 2 values
T-SQL: Inner join on a field with 2 values I have this query on a MS SQL Server 2005: Label_Id is a field containing data like this: I have a custom split Function which returns from a string a table ...
- Modified
- 3 Dec at 03:18
LINQ - Full Outer Join
LINQ - Full Outer Join I have a list of people's ID and their first name, and a list of people's ID and their surname. Some people don't have a first name and some don't have a surname; I'd like to do...
- Modified
- 29 Dec at 01:13
LEFT JOIN only first row
LEFT JOIN only first row I read many threads about getting only the first row of a left join, but, for some reason, this does not work for me. Here is my structure (simplified of course) ``` rel_id | ...
- Modified
- 17 Jul at 14:50
LINQ Joining in C# with multiple conditions
LINQ Joining in C# with multiple conditions I have a LINQ Joining statement in C# with multiple conditions. ``` var possibleSegments = from epl in eventPotentialLegs join sd in segmentDurations on...
- Modified
- 14 Apr at 01:27
Use contains in LINQ to SQL join
Use contains in LINQ to SQL join How can I do a LINQ to SQL join without an exact match? For example, say I have a table `form` with the data `John Smith (2)` and I want to join it to the field `Smith...
- Modified
- 2 Jul at 16:43
SQL LEFT-JOIN on 2 fields for MySQL
SQL LEFT-JOIN on 2 fields for MySQL I have a view `A` and a view `B`. In `A` I have a lot of information about some systems, like `IP` and `port` which I want to preserve all. In `B` I have just one i...
CROSS JOIN vs INNER JOIN in SQL
CROSS JOIN vs INNER JOIN in SQL What is the difference between `CROSS JOIN` and `INNER JOIN`? ``` SELECT Movies.CustomerID, Movies.Movie, Customers.Age,
- Modified
- 12 Dec at 08:55
MySQL Query Join and Count Query
MySQL Query Join and Count Query I'm trying to pull values from a database for a web app where a moderator can add companies to a list of specified industries. This request needs to pull each industry...
Removing extra commas from string after using String.Join to convert array to string (C#)
Removing extra commas from string after using String.Join to convert array to string (C#) I'm converting an array into a string using `String.Join`. A small issue I have is that, in the array some ind...
WHERE conditions in subquery while using ANSI joins
WHERE conditions in subquery while using ANSI joins Why doesn't it work? I get "ORA-00900: invalid SQL statement". Is there a way to use WHERE clause inside the subquery? Edit: Version 9.2 Oracle9i En...
MySQL JOIN with LIMIT 1 on joined table
MySQL JOIN with LIMIT 1 on joined table I want to join two tables, but only get 1 record of table2 per record on table1 For example: This would get me all records in `products`, which is not what I wa...
Does the join order matter in SQL?
Does the join order matter in SQL? Disregarding performance, will I get the same result from query A and B below? How about C and D? ``` ----- Scenario 1: -- A (left join) select * from a left join b...
- Modified
- 26 Nov at 08:29
FULL OUTER JOIN vs. FULL JOIN
FULL OUTER JOIN vs. FULL JOIN Just playing around with queries and examples to get a better understanding of joins. I'm noticing that in SQL Server 2008, the following two queries give the same result...
- Modified
- 29 Sep at 21:47
Update Query with INNER JOIN between tables in 2 different databases on 1 server
Update Query with INNER JOIN between tables in 2 different databases on 1 server Need some SQL syntax help :-) Both databases are on the same server ``` db1 = DHE db2 = DHE_Import UPDATE DHE.dbo.tblAc...
- Modified
- 27 Mar at 17:24
SQL: inner join on alias column
SQL: inner join on alias column Previously I have asked to strip text from a field and convert it to an int, this works successfully. But now, I would like to do an INNER JOIN on this new value. So I ...
- Modified
- 14 Jul at 12:31
1052: Column 'id' in field list is ambiguous
1052: Column 'id' in field list is ambiguous I have 2 tables. `tbl_names` and `tbl_section` which has both the `id` field in them. How do I go about selecting the `id` field, because I always get this...
- Modified
- 15 Jun at 20:22
Appending two dataframes with same columns, different order
Appending two dataframes with same columns, different order I have two pandas dataframes. I simply want to join such that the final DF will look like: ``` click |
How to join on multiple columns in Pyspark?
How to join on multiple columns in Pyspark? I am using Spark 1.3 and would like to join on multiple columns using python interface (SparkSQL) The following works: I first register them as temp tables....
- Modified
- 5 Jul at 08:24
SQL LEFT JOIN Subquery Alias
SQL LEFT JOIN Subquery Alias I'm running this SQL query: An
How do I convert multiple inner joins in SQL to LINQ?
How do I convert multiple inner joins in SQL to LINQ? I've got the basics of LINQ-to-SQL down, but I've been struggling trying to get JOINs to work properly. I'd like to know how to convert the follow...
- Modified
- 31 Mar at 23:37
pandas three-way joining multiple dataframes on columns
pandas three-way joining multiple dataframes on columns I have 3 CSV files. Each has the first column as the (string) names of people, while all the other columns in each dataframe are attributes of t...
Hibernate Criteria Join with 3 Tables
Hibernate Criteria Join with 3 Tables I am looking for a hibernate criteria to get following: Dokument.class is mapped to Role roleId Role.class has a ContactPerson contactId Contact.class FirstName L...
Subselect in a Join - Problem
Subselect in a Join - Problem I've a little Problem with a statement: ``` SELECT p1.Modell_nr, p1.ProductID, p2.count_modlieffarbe_vl, concat(p1.Modell_nr,'_',p1.LiefFarbe) as modfarb_id1 FRO...
- Modified
- 28 Feb at 16:41
MySQL: Quick breakdown of the types of joins
MySQL: Quick breakdown of the types of joins I would like a quick breakdown of the types of MySQL joins. I know of these, the rest I am not sure what they mean. - `SELECT * FROM a, b WHERE b.id = a.be...
how to use a like with a join in sql?
how to use a like with a join in sql? I have 2 tables, say table A and table B and I want to perform a join, but the matching condition has to be where a column from A 'is like' a column from B meanin...
Inner Join: Is this an optimal solution?
Inner Join: Is this an optimal solution? T1: employee [id, salary] T2: department [name, employeeid] (employeeid is a foreign key to T1's id) Problem: Write a query to fetch the name of the department...
- Modified
- 11 Dec at 19:46
SQL join on multiple columns in same tables
SQL join on multiple columns in same tables I have 2 subqueries, but I'm having trouble joining columns together from the same tables. I tried: ``` SELECT * FROM (SELECT userid, listid FROM user_views...
Pandas join issue: columns overlap but no suffix specified
Pandas join issue: columns overlap but no suffix specified I have the following data frames: When I try to join these data frames: ``` j
Need help joining table
Need help joining table I have a function that exports a table to CSV and in the query I set which fields will export. Here is the query: The field venue_id is the the id of the venue which is referre...
MySQL INNER JOIN select only one row from second table
MySQL INNER JOIN select only one row from second table I have a `users` table and a `payments` table, for each user, those of which have payments, may have multiple associated payments in the `payment...
- Modified
- 27 Feb at 14:49
Join two sql queries
Join two sql queries I have two SQL queries, where the first one is: and the second one is: ``` select Activity, SUM(Amount) as "Total Amount 2008" from Activities, Incomes2008 where Activi
Left Join With Where Clause
Left Join With Where Clause I need to retrieve all default settings from the settings table but also grab the character setting if exists for x character. But this query is only retrieving those setti...
- Modified
- 20 Jan at 20:59
SQL Joins Vs SQL Subqueries (Performance)?
SQL Joins Vs SQL Subqueries (Performance)? I wish to know if I have a query something like this - and a something like this - When I consider which of the two queries would be faster and ? Also is the...
- Modified
- 29 Nov at 04:37
Linq join without equals
Linq join without equals I have a list of rectangles and a list of points. I want to construct a LINQ query that will match the list of points with their corresponding rectangles. Something like this:...
Select rows which are not present in other table
Select rows which are not present in other table I've got two postgresql tables: I want to get every IP address from `login_log` which doesn't have a row in `ip_location`. I tried this query but it t...
- Modified
- 4 Jan at 16:59
How to specify names of columns for x and y when joining in dplyr?
How to specify names of columns for x and y when joining in dplyr? I have two data frames that I want to join using dplyr. One is a data frame containing first names. ``` test_data
SQL join: selecting the last records in a one-to-many relationship
SQL join: selecting the last records in a one-to-many relationship Suppose I have a table of customers and a table of purchases. Each purchase belongs to one customer. I want to get a list of all cust...
- Modified
- 14 Dec at 17:47
LEFT OUTER JOIN in LINQ
LEFT OUTER JOIN in LINQ How to perform left outer join in C# LINQ to objects without using `join-on-equals-into` clauses? Is there any way to do that with `where` clause? Correct problem: For inner jo...
vlookup in Pandas using join
vlookup in Pandas using join I have the following 2 dataframes I want to perform a merge, or join opertation using Pandas (or whichever Python operator is best) to produce the below data frame. ``` Ex...
How to join 3 tables with lambda expression?
How to join 3 tables with lambda expression? I have a simple LINQ lambda join query but I want to add a 3rd join with a where clause. How do I go about doing that? Here's my single join query: ``` var...
T-SQL: Selecting rows to delete via joins
T-SQL: Selecting rows to delete via joins Scenario: Let's say I have two tables, TableA and TableB. TableB's primary key is a single column (BId), and is a foreign key column in TableA. In my situatio...
LINQ: combining join and group by
LINQ: combining join and group by I have a query that combines a join and a group, but I have a problem. The query is like: ``` var result = from p in Products join bp in BaseProducts on ...
- Modified
- 30 Sep at 12:43
SQL JOIN, GROUP BY on three tables to get totals
SQL JOIN, GROUP BY on three tables to get totals I've inherited the following DB design. Tables are: My query needs to return invoiceid, the invoice amount (in the invoices ta
SQL Query with Join, Count and Where
SQL Query with Join, Count and Where I have 2 tables and am trying to do one query to save myself some work. I want to join them so that I get `id, category id, category name, colour` Then I want to l...
- Modified
- 19 Jul at 16:49
Count with IF condition in MySQL query
Count with IF condition in MySQL query I have two tables, one is for news and the other one is for comments and I want to get the count of the comments whose status has been set as approved. ``` SELEC...
- Modified
- 31 Mar at 12:43
Unable to create a constant value of type Only primitive types or enumeration types are supported in this context
Unable to create a constant value of type Only primitive types or enumeration types are supported in this context I am getting this error for the query below > Unable to create a constant value of typ...
- Modified
- 13 Oct at 11:10
ServiceStack OrmLite LeftJoin Issue
ServiceStack OrmLite LeftJoin Issue I'm using ServiceStack OrmLite JoinSQLBuilder with a left join and have found an issue. Suppose I have 2 tables, TableA and TableB and wanted to join on more than a...
- Modified
- 23 May at 12:20
SQL query: Simulating an "AND" over several rows instead of sub-querying
SQL query: Simulating an "AND" over several rows instead of sub-querying Suppose I have a "tags" table with two columns: and . Each row represents a tag assigned to a piece of content. I want a query ...