join

unix join separator char

Sorry for the maybe trivial question. I fought a bit with the unix join command, trying to get tabs instead of whitespaces as the default separators. -t is the argument, but these don't work (ubuntu 9.10 64 bit 2.6.31-14, GNU coreutils version 7.4) join file1 file2 -t"\t" join file1 file2 -t="\t" join file1 file2 -t="\\t" join file1 fi...

mySQL - Insert into three tables

I recently asked this question. I have a relational database with three tables. The first containts id's that relate to the second. The second contains id's that relate to the third. The third contains the results I am after. Is it possible with a single query to query an id in the first table which g...

thread termination issue (c programming)

I'm working on an application for Linux in C which uses multiple threads. The threads which are spawned by the main function do most of the work, and therefore usually finish last. I'm seeing some strange behavior, and I believe it's due to the main thread terminating before the spawned threads have a chance to finish their jobs. Here's ...

Using annotations to implement a static join in hibernate

Hi, I'm relatively new to hibernate and was wondering if someone could help me out. While I have no issues implementing a normal join on multiple columns in hibernate using the @JoinColumns tag, I'm stumped when trying to implement the following query in annotations: SELECT A.* FROM TABLEA A LEFT OUTER JOIN TABLEB B ON A.UID = B.ID AND...

sql joins and getting used to them

Hi, I had a big interview that I screwed up when the interviewer asked me to join three tables. I can verbally describe the different types of joins, but I froze up. I'm looking for something that gets me used to these types of problems so I can anticipate how to solve them. Anybody have any SQL excercises they could possibly recommen...

Connecting two WPF canvas elements by a line, without using anchors?

I have a canvas for diagramming, and want to join nodes in the diagram by directed lines (arrow ends). I tried the anchor approach, where lines only attach at specific points on the nodes but that did not work for me, it looked like crap. I simply want a line from the centre of each object to the other, and stop the line at the nodes' e...

Can't use "Skip" in LINQ query

I have a linq query in which I need to specifically do a left join. However when I attempt to commit a lambda Skip function on the query it errors and says that the skip cannot be performed on a linq query with a join. Here's the query (the skip variable is a parameter into the function and clientDB is the datacontext): Dim...

Tips or tricks for translating sql joins from literal language to SQL syntax?

I often know exactly what I want, and know how tables are related in order to get it, but I have a real hard time translating that literal language knowledge to SQL syntax when it comes to joins. Do you have any tips or tricks you can share that have worked for you in the past? This is a basic, but poor example: "I have Categories, whi...

Linq - How to turn IQueryable<IEnumerable> into IQueryable

Hi, I have a simple linq statement that isn't quite returning what I would like. I understand why, I just don't know how to wriet it to get what I want. The query is as follows: answers = from a in ents.tblCalls where a.tblSessions.tblUsers.UserID == UserID.Value && (a.StartTime >= sta...

Select from multiple tables matching multiple criteria

Hello, I am working with 3 tables, trying to pull a list that match certain criteria. I need a list of companies from the companies table, that have an active opportunity (iactive is 1 in opportunities table) AND have a record in the notes table of type order or order2. Companies Table +------+------------------+ | cid | ccyname ...

SQL Server - Selecting records with specific, multiple entries in an associative table

I’m working in SQL Server with the following sample problem. Brandon prefers PC’s and Macs, Sue prefers PC’s only, and Alan Prefers Macs. The data would be represented something like this. I've had to make some compromises here but hopefully you get the picture: TABLE 1: User uID (INT PK), uName (VARCHAR) 1 'Brandon' 2 ...

MYSQL Inner Join with 2 ON Clauses

I am trying to setup a simple database in which I have a user and store both their residential and postal address. I have 2 tables Users id (Primary Key) name (Varchar 255) residential_id (foreign key) postal_id (foreign key) Address id (primary key) type (enum of R and P) street (varchar 255) suburb (varchar 255) I am tring ...

MySQL deleting multiple columns from two table

Hello. I have Two tables like this: Table categories: columns: id, name, parent 1, Foods, 0 2, Drinks, 0 3, FastFood, 1 4, Hamburger, 3 Table documents: columns: id, name, categoryID 1, CheseBurger, 4 2, shop, 3 the parent column has the parent category's id. So When i want to delete Foods entry from categories, i want to delete all ...

Simplest way to do a recursive self-join in SQL Server?

What is the simplest way of doing a recursive self-join in SQL Server? I have a table like this: PersonID | Initials | ParentID 1 CJ NULL 2 EB 1 3 MB 1 4 SW 2 5 YT NULL 6 IS 5 And I want to be able to get the records only related to a...

SQL Joins, Count(), and group by to sort 'posts' by # of yes/no 'votes'

I have posts, votes, and comments tables. Each post can have N 'yes votes', N 'no votes' and N comments. I am trying to get a set of posts sorted by number of yes votes. I have a query that does exactly this, but is running far too slowly. On a data set of 1500 posts and 15K votes, it's take .48 seconds on my dev machine. How can I opti...

Linq with array

Dim Cozinhas as string = "1, 2, 3" Dim FiltroCozinha() As String = Cozinhas.Split(",") Dim Empresas = (From E In lstEmpresas _ Group Join CE In lstCozinhasEmpresas On CE.EmpresaID Equals E.EmpresaID Into CEJ = Group From CE In CEJ.DefaultIfEmpty() _ Group Join FC In lstFiltroCozinha On FC Equals CE.Cozinh...

difference between join and no join select ?

Greetings all, I see no difference between the two queries below: query_join = select a.id, b.name, a.telephone, a.description from tb_industry a left outer join tb_sector b on a.sector_id = b.id query_select = select a.id, b.name, a.telephone, a.description from tb_industry a , tb_sector b WHERE a.sector_id = b.id The result is ...

linq query from more tables

public ActionResult myItems() { var dataContext = new RecordsDataContext(); MembershipUser myObject = Membership.GetUser(); string CurrentUserName = myObject.UserName.ToString(); var user = from i in dataContext.myUsers where i.userName ==CurrentUserName ...

SELECT TOP 1 in a many to many query

I have a faily simple many to many schema, which looks like this: What I'm trying to do is select all players with some arbitary conditions and I also want to select their most recent match, if they've played in one. What I've managed to do is: SELECT tblPlayer.PlayerId, tblPlayer.Surname, tblPlayer.Forename, (SELECT TOP 1 tblMatch.Ho...

SQL to Linq translation with inner join and 2 left joins (with sub-query)

Hi there! I have the following query which works fine in SSMS. Im using LinqPad (C#) but really puzzling to succeed with the left outer join in LinqToSql: SELECT DISTINCT A.LocID, V1.PrfValue AS pID, V2.PrfValue AS sID, D.DivisionManager, A.IsApproved, A.DateCreated FROM dbo.Locations AS A INNER JOIN dbo.D...