join

When to add index on joined tables

I have a mysql table with 9 million records that doesn't have any indices set. I need to join this to another table based on a common ID. I'm going to add an index to this ID, but I also have other fields in the select and where clause. Should I add an index to all of the fields in the where clause? What about the fields in the s...

LINQ to XML perform distinct and join between files

Hello all, I am working with some large XML files using LINQ to XML. Now, a typical XML file returns: ID Name Image URL I get a lot of duplicate information, I consider duplicate information to be data with the same ID ( it could have different a name and images and I don't mind). I want to distinct the values of the first XML file ...

How to join the results of two subqueries in PostgreSQL?

hello i'm newbie in sql (postgresql) i have 2 tables as result of 2 differen selects all calls our customer contacts number contact_id and contact_id name 3213 12 12 jonh 3213 34 16 michael 3213 43 ...

SQL WHEREing on a different table's COUNT

So, I want to apply a WHERE condition to a field assigned by a COUNT() AS clause. My query currently looks like this: SELECT new_tags.tag_id , new_tags.tag_name , new_tags.tag_description , COUNT(DISTINCT new_tags_entries.entry_id) AS entry_count FROM (new_tags) JOIN new_tags_entries ON new_tags_entries.tag_id = n...

Please suggest how to achieve this with joins

I need to write queries to find out new users and regular users. new users are the ones whose uuid appeared in last 24 hours (from now minus the time query is fired) in table2 and was not there before. regular users are the ones whose uuid appeared in last day in table2 and was also there at least once in the last 3 days. In addition ...

Determine 'valid until' date in MySQL query

In this table I store changeable values for certain spids. As days go by, these values can change, and an spid can get a new value. Now I want to find out until when a certain value is enabled. This is the data for a single spids uid spid propertyvalue creationdate -------------------------------------------------- 1 3 ...

A light weight Scala fork join syntax

Despite the upcoming java 7 standard fork/join framework, I am building some helper method that is light weight in syntax for client to run code in parallel. Here is a runnable main method to illustrate the idea. import actors.Futures object ForkTest2 { def main(args: Array[String]) { test1 test2 } def test1 { v...

SQL query with limit on rows from one table, not the result set

I'm running a simple query with a join, similar to SELECT t1.a, t2.b FROM t1 LEFT JOIN t2 ON ... LIMIT 5 As t1 has-many rows in t2 ( any number above 2 ) the LIMIT statement does not return the first 5 rows from t1 and corresponding entries from t2, but 5 rows which usually include 2-3 rows from t1. How can I write this query to get ...

Joining tables in MySQL question (php)

Hi, Situation: In my database I have a table called 'artists' and 'tags'. Each artist has a set of tags, saved in a linking table 'artisttags'. Each unique tag is saved in a table called 'tags'. Problem I would like to show all artists that have one (or more) tags in common with a given artist. function getSimilarArtists($artist_...

Optimizing multiple joins

Hi folks, I'm trying to figure out a way to speed up a particularly cumbersome query which aggregates some data by date across a couple of tables. The full (ugly) query is below along with an EXPLAIN ANALYZE to show just how horrible it is. If anyone could take a peek and see if they can spot any major issues (which is likely, I'm not ...

Joining DataSets in ReportingServices

I have a SSRS report. This report has two data sets from two different data sources. I need to do a conceptual join on these two data sets. For example, assume I have the following datasets A and B. DataSet A Data Source is SqlServer P SELECT user_id, user_name from users DataSet B Data Source is SqlServer Q SELECT change_id, user_i...

Why doesn't .join() work with function arguments?

Why does this work (returns "one, two, three"): var words = ['one', 'two', 'three']; $("#main").append('<p>' + words.join(", ") + '</p>'); and this work (returns "the list: 111"): var displayIt = function() { return 'the list: ' + arguments[0]; } $("#main").append('<p>' + displayIt('111', '222', '333') + '</p>'); but not thi...

Simple MySQL Join problem

Im stumped by this simple query because its one I have not tried before. Ive got a User table, User_Widget table and a Widget table. A simple inner join shows me what widgets they have by joining user_widget.user_id = user.user_id. How would I show the widgets in the Widget table that they dont have? ...

LINQ join with filter criteria

How is something like this done in linq? It has filter criteria on the JOIN. This is taken from this question: http://stackoverflow.com/questions/1401889/sql-filter-criteria-in-join-criteria-or-where-clause-which-is-more-efficient select salesman.salesmanid, max(sales.quantity) from salesman inner join sales on salesman.salesmanid =sa...

join three tables in sql server 2005

Hai guys, I ve thus far used join with two tables but now i want to join three tables which is shown in the below fig I ve tried to join two tables, SELECT O.OrderID,O.CustID,O.OrderTotal,C.Name from Orders as O inner join Customers as C on O.CustID=C.CustID how to join the third table with this.... Any suggestion... ...

Edit query in MS-Access with a subquery containg a SUM() field

When I open this query in Access (which is just a collection of 2 linked tables) I'm able to edit the data with no problems whatsoever. SELECT O.*, PP.skuapexid FROM tblSkuBestellingen AS O INNER JOIN tblSkuApex AS PP ON (PP.begindatum <= O.besteldatum) AND (PP.sku = O.sku) WHERE NOT EXISTS ( SELECT * FROM tblSkuApex PP2 ...

MySQL join performance vs correlated queries

Hi, I'm wondering if a 'normal' inner join leads to higher execution performance in MySQL queries than a simplistic query where you list all tables and then join them with 'and t1.t2id = t2.id' and so on .. ...

SQL - join up two separate sql queries

Hi - I have a table that stores the page hits on a web application, storing unique_row_id http_session_id page_name page_hit_timestamp ---------------------------------------------------------------- 0 123456789 index.html 2010-01-20 15:00:00 1 123456789 info.html 2010-01-20 15:00:05 2 ...

WordPressMU - get blog list, alphabetically sorted by blogname

In WordPress MU, I've tried writing my own query for this but can't seem to get all of the joins I really need. The result set I'm looking for would be something like: blog_id blog name blog path owner first name owner last name and return it all alphabetically, by blog name. The trouble I'm having is that the first and last name of t...

How can I join two Matrix in Java

Hello I want to join 2 matrix with the same number of columns and different number of lines, but I'm wondering how can I do this with one command. I already know how to do this using for's, then, I want to know if there is a command in Java that do the job for me. For example int m1[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int m2[][...