A SQL JOIN clause combines records from two or more tables in a relational database.

learn more… | top users | synonyms

3
votes
1answer
14 views

SQL report of subscribers and their associated revenue

A user can have many subscriptions, and a subscription belongs to one plan. The plans table tells us a subscription's cost. Is the query below the correct one for ...
3
votes
1answer
101 views

Joining huge CSV files and splitting the result into batches

I've got ~20GB of data about the same subject, concatenated from small files of 16kB, each produced by different measurement equipment. They share some headers (on the example: B, D & E) and they ...
1
vote
0answers
25 views
3
votes
0answers
22 views

Updating ActiveRecord with text from a joined table

I have an Active Record update with the following data model: TvMenuProfile has one rich_text_special ...
25
votes
5answers
3k views

Performance of a Foreach inside a Foreach iterating through a million records

I have two DataTables: dt: is populated from a CSV file with over 1.7 million rows dataStructure.Tables["AccountData"]: is ...
2
votes
1answer
20 views

Collating client ratings

The code is fetching records from a table called CSAT_SUMMARY_REPORTS[driver table] but due to the filters conditions applied which needs to be checked in another ...
5
votes
1answer
54 views

Report for a restaurant showing hourly sales information for a given timespan

I have been tasked with creating a report for a high-volume restaurant that shows hourly sales information for a given timespan. When generating this report for a single day, it's very quick, but when ...
4
votes
1answer
35 views

Fetching all the project's items for a specific project id

In the following query, I am fetching all the projects items with specific project id. At the same time, I am using a join in Select to fetch the delivered quantity of items of this project only. The ...
8
votes
2answers
56 views

Iterate list to map entries in Python

I have two files, namely: File1: CL1 AA XX YY ZZ SS \n CL2 3_b AA File2: AA string1 AA string2 3_b string3 My ...
3
votes
1answer
72 views

Scanning multiple huge files in Python (follow-up)

I'm trying to implement an algorithm able to search for multiple keys through ten huge files in Python (16 million of rows each one). I've got a sorted file with 62 million of keys, and I'm trying to ...
3
votes
2answers
81 views

Selecting product variants that satisfy all option criteria

My current query: ...
1
vote
1answer
29 views

Combining MySQL Left Join results [closed]

I'm trying to get the End result. I already done it with 2 different queries. Is there a better way without UNION or which one is the best? ...
3
votes
2answers
67 views

Join JSON objects on common property

is there an easier/more efficient way to join two JSON objects on a common property than this? It's a GeoJSON file (basically an array of objects), and I want to pull in a property from another JSON ...
1
vote
1answer
40 views

Prices and contracts query

The query below is quite slow (taking about half a second). Any obvious things I could improve? The PRICES table has about 21 million rows and 30 columns while ...
3
votes
1answer
820 views

Using LINQ to perform a LEFT OUTER JOIN in 2 DataTables (Multiples criteria)

I know that exists a lot of solutions about how to create an OUTER JOIN between two DataTables. I created the following code in ...
2
votes
1answer
29 views

MSSQL query with join and where clause

I've the following tables ...
3
votes
1answer
33 views
1
vote
1answer
49 views

Archiving an SQL table of sessions and statistics

What my query is doing: I have two SQL tables and I want to copy datarows from the one table to the other table. I am doing this for statistics. The source table includes all current ...
10
votes
1answer
94 views

Aggregating 2 lists by matching UniqueIDs

This Macro takes my company's 2 main sources of all-client data (each a data table in a separate worksheet) and aggregates them into a 3rd list, by matching a unique account number (for clients that ...
0
votes
2answers
510 views

MySQL JOIN to JSON array

I'm building a HTTP API and this part should return a JSON list of posts and their attached photos, like this: ...
0
votes
0answers
50 views

Health insurance claims query involving joins to fetch one column

General feedback is welcome, but I am especially wondering if there is a way to make things more efficient where I am joining an entire large table to gain use of one column (like when I join tables ...
2
votes
1answer
268 views

Returning IQueryable<T> from my repository in Repository pattern design pattern

I am developing an application based on Repository design pattern. What should be the return type from the Repository? This is my UserRepository class: ...
2
votes
0answers
59 views

groupJoin() in Swift

I have created the following function in Swift for this library I am writing, which joins two arrays on a key (extracted using given closures), and then groups them by key in a ...
1
vote
0answers
106 views

Natural join row comparison

The intent of the function is to simply tell me whether or not two vectors contain the same values that have the same column names. At this point of my algorithm I'm just checking the whether or not I ...
5
votes
1answer
100 views

Fetching player data

I would like to select some information I have stored in my MySQL DB. I have 2 tables named gameTable and playerTable. Now I ...
2
votes
2answers
151 views

Query using cross join or inner join

Please consider the following three tables that I am playing with in the image below: I want to come up with a SQL Query which shows first_name, last_name, and the total amount of all orders for ...
3
votes
1answer
49 views

Join - order by vote-sum and check if user has voted

I have a vote and a comment table. Now I want to display all comments and order them by votes-sum. Sum because some votes can have a higher value than others. Therefore I want to display if the user ...
2
votes
1answer
52 views

Select Queries From Parent-Child Tables Model

I have two tables (parent-child model): Loans & Transactions. Each Loan row has multiple Transaction rows. I want to select all rows from Loans together with most recent row from Transactions. ...
11
votes
4answers
2k views

LW, MTD, STD, YTD Sales… all in line and looking pretty

That's Last Week, Month-to-Date, Season-to-Date, and Year-to-Date sales. I have a table-valued function for each one, that takes a date and returns all ...
7
votes
1answer
60 views

Joining collections… because it's fun

I'm working on a LinqEnumerable class (reviewable here), and I'm no Big-O expert and I'm pretty bad with algorithms, so I wonder what the complexity is for what ...
7
votes
3answers
258 views

Normalizing Invoices

I need to move data from one database to another, and since I don't have SSIS I'm doing this ETL with T-SQL scripts. One of the source tables contains invoice details, and features a column that ...
3
votes
1answer
69 views

Merging totals from rows with duplicate IDs

I have the following query which updates the quantity when there are duplicate items and users (there should only ever be 2 duplicates), then deletes the row which doesn't get updated... ...
7
votes
3answers
6k views

Extracting data from text file in bash using awk, grep, head and tail

I've been writing bash script on and off, with pretty good results in terms of getting the job done. However, I'm worried that my script might be very ugly, as I am a beginner. I'm looking for advice ...
5
votes
1answer
58 views

I think I should use JOIN but I did this instead

Let me start by saying that I am brand new to PHP and MySQL. I have two tables. One table is called domains and it contains the "rep" column which is an integer. It is related to the column "id" in ...
5
votes
1answer
76 views

Library database search with multiple JOINs is too slow

I have a MySQL query which runs very slowly. I've rewritten it many times but no improvements yet. My current query for advanced search takes about 60 secs to complete. Any suggestions for improving ...
3
votes
1answer
130 views

Moonshot & `Thread.Abort` - dealing with the fallout

Recently, I encountered an anomaly in the manner by which a worker thread was terminated. It prompted me to do some searching and I realized that I was constructing thread code in a haphazard manner. ...
2
votes
1answer
137 views

Displaying subcategories of subcategories

I wanted to know if this code is safe against SQL injection or not? Also do I need to mysqli_close if I already did the ...
11
votes
3answers
230 views

Geographic search

I have this table (inradar_ad) with almost 300k entries. I want to know why my query takes 160 secs to run. I tried limiting with ...
4
votes
2answers
131 views

Data screening using Perl

Background information I've been asked to write a little Perl script that allows genomic data to be screened against reference files in order to determine locations of specific mutations. The input ...
7
votes
1answer
120 views

A faster way to combine two SQL table

I would like to give it a try and ask about my codes on here from now on to see if there are improvement for'em this code is supposed to combine two sql tables into one. ...
2
votes
1answer
60 views

Join of two databases

This is the most basic code to join two tables in a database. For tables it uses a simple list. Solved this using brute force, sorting and using hashtable. ...
3
votes
2answers
268 views

Optimizing join statement

I have this piece of code: ...
5
votes
1answer
1k views

SQL cross join and multiple joins

Is there a way to improve this SQL query? It involves multiple cross join and joins. I have 3 tables, and I want to compute the cardinal product: ...
0
votes
2answers
1k views

Make a MySQL SELECT and INNER JOIN faster

I have the following query which works as it should, but I'd like to know how I can make it run faster. For info, tables cl, ...