inner-join

ms access complicated query. querying last two entries by date for each ID. very slow

I have two tables. Widgets, which has information about each widget (Color, size, etc); each widget has a unique ID, WidgetID. The other table is Tests, and it contains information about multiple tests that were run on each widget. This table, therefore, has multiple rows for each WidgetID. It contains information that we can call (Widg...

LINQ: Associations not functioning correctly for use with innerjoins

Hi there, Can anyone help, I have been using linq2sql with great success using my associations (foreign keys) to provide inner joins etc... for example this, works great, the color is stored in a table called Color which has association so i pick it up via Color.Description - Excellent. Same for StructureType its actually an associati...

LINQ: Using a pivot table in linq

Hi there, Can anyone help? I have the following structure using associations, and as you can see v.StructureType.Description works great as its a 1 to 1 association, but i need to get in my example below v.StructureGroup.StructureGroupTariffs.Tariff.Price but StructureGroupTariffs is a Pivot table to interlink the StructureGroup and Ta...

How do I force SQL Server 2005 to run a join before the where?

I've got a SQL query that joins a pricing table to a table containing user-provided answers. My query is used to get the price based on the entered quantity. Below is my SQL statement: SELECT JobQuestion.Value, Price.Min, Price.Max, Price.Amount FROM Price INNER JOIN JobQuestion ON Price.QuestionFK=JobQuestion.QuestionFK ...

Help with linq join

Hi there, I have the following expression in linq (its a join) and i am selecting into "J" because i need to use J later (currently i just selecting J but once i have this fixed i plan on use J within another subquery after) But it won't let me supply a where using the "V" side hence v.IdOFfice is invalid. I have tried swapping around ...

LINQ; forcing a new {} to return Iqueryable?

Hi there, I written a small query and in Linqpad its working well but (see below) Tariffs is not returned as Iqueryable, does anyone know how to fix this ? Basically see Tariffs = new ...., from v in House join gvt in (from t in MyTariffs where t.Id == 3 select t) on v.IdTariff equals gvt.Id select new { Id = v.Id, Tariffs =...

When do i use inner joins and when do i use subqueries?

What is the difference between an inner join and a subquery? and when should i use a subquery? or an inner join? I was in a situation recently where an inner join was too slow and subquery was the solution. From my limited understanding i thought the two worked exactly the same. ...

Join to give list with optional relationship column

Here are the tables: sets: id INT users: id INT items: id INT setid INT [an item only belongs to one set] relationships: userid INT itemid INT relationship WHATEVER Now, I have been trying to write an SQL query to do the following, without much success. Given a ...

SQL: Inner joining two massive tables

Good afternoon, I have two massive tables with about 100 million records each and I'm afraid I needed to perform an Inner Join between the two. Now, both tables are very simple; here's the description: BioEntity table: BioEntityId (int) Name (nvarchar 4000, although this is an overkill) TypeId (int) EGM table (an auxiliar table, in...

SQL Server: Design: Embedded Select statement or INNER JOIN ?

I've the following table structure - Site: Master tablefor site Org: Master table for Org User: Master table for User (each user links to a unique Org via User.OrgId) OrgSite: Store some 'Org specific' Site details (OrgId, SiteId, SiteName, SiteCode). Not ALL sites but only those which are accessible to Org. ...

SQL query problem with AND

I have a table that holds topic types another that holds materials. I then have another table which holds the keys of each table thus creating the many to many relation. However, when I try to search the topics to pick out two topics which have share the same material it doesn't work. Example tables: Material Table: MatID | Name ---...

inner joins in oracle

I was thinking about the syntax of inner joins in Oracle's SQL implementation and here is something that seems a bit inconsistent: Let's say you have two relations loan(loan_number, branch_name, amount) and borrower(customer_name, loan_number). loan_number is the attribute common to both tables. Now, Oracle gives you two ways to express...

Best way to do an Inner Join using the Zend Framework?

It seems like there's a few different ways to join two tables using the Zend Framework, but I've never done it before so I don't know which is the best way to do it. This is what I'm trying to do... I have 3 tables in my database: users ( id , name ) groups ( id , name ) group_members ( id , group_id , user_id ) I'm tryi...

MySQL query using INNER JOIN, Not returning what i'd expect.

Hi, I'm having trouble with the following query: SELECT costingjobtimes.TimeStamp, costingdepartment.DeptDesc, costingemployee.Name, costingjobtimes.TimeElapsed FROM costingemployee INNER JOIN (costingdepartment INNER JOIN costingjobtimes ON costingdepartment.DeptID = costingjobtimes.DeptID) ON costingemployee.EmployeeID = costingjobt...

Help with MySQL Query

Hello. I have two tables in my database, and I would like to retreive information from both of them without having to do two queries. Basically, the user_ID(s) retreived from the tasks table needs to be used to get those respective user(s) names from the users table. This is what I have so far, but the query is returning false: SELEC...

Compare inner join and outer join SQL statements

What is the difference between an inner join and outer join? What's the precise meaning of these two kinds of joins? ...

Java JPA Inner JOIN with WHERE statement

Hi folks, I want to annotate following structure: I have this query: SELECT A.*, BES.*, BES_2.* INNER JOIN BES ON A.a = BES.a AND A.b = BES.b INNER JOIN BES AS BES_2 ON A.a = BES_2.a AND A.b = BES_2.b WHERE (BES.c = N'foo') AND (BES_2.c = N'bar') I have the entities Job (representing A) and JobEndPoint (representing BES). The Job...

Left JOIN faster or Inner Join faster?

So... which one is faster (NULl value is not an issue), and are indexed. SELECT * FROM A JOIN B b ON b.id = a.id JOIN C c ON c.id = b.id WHERE A.id = '12345' Using Left Joins: SELECT * FROM A LEFT JOIN B ON B.id=A.bid LEFT JOIN C ON C.id=B.cid WHERE A.id = '12345' Here is the actual query Here it is.. both return the same...

Join results of two select statements

Hey all- I have a table serving as a transaction log: Date Action Qty 11-23 ADD 1 11-23 REMOVE 2 11-23 ADD 3 I would like a query to aggregate all of ADDs and all of the REMOVEs separately for a given date. Each of these select statements work fine, but they cannot be joined: select date, sum(qty) as Added from tabl...

Need help with designing a query in ELinq

This is my query: Dim vendorId = 1, categoryId = 1 Dim styles = From style In My.Context.Styles.Include("Vendor") _ Where style.Vendor.VendorId = vendorId _ AndAlso (From si In style.StyleItems _ Where si.Item.Group.Category.CategoryId = _ categoryId).Count > 0 _ ...