join

Combining 2 .csv files by common column.

So I have two .csv files where the first line in file 1 is: MPID,Title,Description,Model,Category ID,Category Description,Subcategory ID,Subcategory Description,Manufacturer ID,Manufacturer Description,URL,Manufacturer (Brand) URL,Image URL,AR Price,Price,Ship Price,Stock,Condition The first line from file 2: Regular Price,Sale Price...

Using Lucene like a relational database

I am just wondering if we could achieve some RDBMS capabilities in lucene. Example: 1) I have 10,000 project documents (pdf files) which have to be indexed with their content to make them available for search. 2) Every document is related to a SINGLE PROJECT. The project can contain details like project name, number, start date, end dat...

C# Linq Delete over Join

Hello, I have a Question table which joins to a Solution table. The solutions are linked to the questions but in order to delete a question, i must delete the solutions for that question first and then delete the question itself. I have a linq query that retrieves all solutions for a specified question however i am unsure how to proceed...

C# joining threads in background worker DoWork()

Hello, In my DoWork() function I register with our sip server. Then I have to wait for a response back. However, the response I get is received in another event. However, before I am able to check the flag in the DoWork() the DoWork() has all ready finished and the response comes after. I am trying to find a way to wait in the DoWork(...

Question about joining two mysql tables.

I am trying to join two tables; the purpose being able to search and display event information for an artist that is entered by the user. The tables are as follows: artist table: [id],[name] events table: [id],[artist_id],[venue_name],[city],[state],[date],[time] I created a search engine, but what I want to do is when an artist name...

Advanced multiple join in subquery using LINQ

I have spent the afternoon trying to wrap my mind around how to translate the following query into LINQ, but I can't quite get there. declare @productId int; set @productId = 3212; select * from InformationData data where productId = @productId and orgId = 1 and exists( select id from ( select coalesce(id1.id, id2.id, id3.id)...

SQL cartesian join problem

I have three tables A: A.pID primary key, A.Name nvarchar(250) B: B.pID primary key, B.Name nvarchar(250) C: C.pID primary key, C.Name nvarchar(250) There is a m to n relation between A and B (table lA_B with primary key lA_B.pID and .pInstanceA Foreign key to table A and .pInstanceB Foreign key to table B) There is a m to n rela...

T/SQL Puzzle - How to join to create one-to-one relationship for two unrelated tables?

Let's assume that I have two tables... Foo and Bar. They contain the following data. Table Foo: Foo_Id ------ 100 101 Table Bar: Bar_Id ------ 200 201 As you can see, each table has two records. I'd like to join these tables together in a way where they return two records; the ultimate goal is to create a one to one relationship f...

ActiveRecord MySQL and JOINS

Hey, I have a problem very similar to the one exposed here in RubyOnRails Guide. This query : Client.all :joins => :orders, :conditions => { :orders => {:created_at => time_range}} should return all the clients with their orders if they made some orders within the time range. Am I right? What I want is slightly differen...

MySQL: duplicating data vs. join

Assuming I have two tables: source, and article and I wish to read article with specific details its source, I can either (1) use join for the two tables; or (2) duplicate the details to the article-record (which will make the data-unit larger, but the query will be very simple). which would be more efficient? ...

COUNT in a query with multiple JOINS and a GROUP BY CLAUSE

I am working on a database that contains 3 tables: A list of companies A table of the products they sell A table of prices they offered on each date I'm doing a query like this in my php to generate a list of the companies offering the lowest prices on a certain product type on a certain date. SELECT a.name AS company, c.id, M...

Query objects from a Many to Many look-up table

I have Master1 and Sub1 and a another called Master1Sub1_Map which contains foreign keys to the Master1 and Sub1 objects. There are multiple ID's from Sub1 that are associated with a single id in Master1. If I want to see all the Sub1 records that are assigned to a specific Master1.ID how do I go about doing that with the SubSonic obje...

How to load data in a Ruby on Rails Join Table ?

Hello I have the following join table that works: class CreateRolesUsers < ActiveRecord::Migration def self.up create_table :roles_users,:id => false do |t| t.integer :role_id, :null => false t.integer :user_id, :null => false end end def self.down drop_table :roles_users end end But I don't know h...

LINQ - Joins in a dynamic query

Because of some business decisions I need to change a bit of what I was doing. Yay me. :) Currently, I have: public IOrderedQueryable<ProductDetail> GetProductList(string productGroupName, string productTypeName, Dictionary<string,List<string>> filterDictionary) { string whereClause = "ProductGroupName='" + productGroupName + "' ...

What indexes optimize this query with four joins?

I have an sql query with inner joins of four tables that takes more than 30 seconds with the current indexes and query structure. I would like to make it as fast as possible; at least faster than 5 seconds. I first thought about denormalizing, but read here that generally it should be possible to optimize via correct indexes etc. I cann...

Determining items that join against the same set in T-SQL

I am writing a a report and was wondering if there is there any way to find items that join into identical sets? For example in the following query, I want to find all areas that join against the same set of products: SELECT Area.Name, AggregateSetOfProductsId FROM Area INNER JOIN AreaToProduct ON AreaToProduct.AreaId = Area.Id GROUP ...

Avoiding a nested subquery in SQL

I have a SQL table that contains data of the form: Id int EventTime dateTime CurrentValue int The table may have multiple rows for a given id that represent changes to the value over time (the EventTime identifying the time at which the value changed). Given a specific point in time, I would like to be able to calculate the count of d...

SQL Server equivalent of MySQL's USING

In MySQL, you can use the keyword USING in a join when you join on columns from different tables with the same name. For example, these queries yield the same result: SELECT * FROM user INNER JOIN perm USING (uid) SELECT * FROM user INNER JOIN perm ON user.uid = perm.uid Is there an equivalent shortcut in SQL Server? ...

MySQL multiple right joins

mysql> select * from product; +------------+---------------+ | product_id | name | +------------+---------------+ | 1 | Car | | 2 | House | | 3 | Cat | | 4 | Blank Product | +------------+---------------+ 4 rows in set (0.00 sec) mysql> select * from tag; +----...

SQL join condition A=B or reverse to B=A?

I don't think it makes any difference to the database, but when joining tables, which order do you prefer to write the condition: SELECT ... FROM AAA INNER JOIN BBB ON AAA.ID=BBB.ID WHERE ... OR SELECT ... FROM AAA INNER JOIN BBB ON BBB.ID=AAA.ID WHERE ... ...