join

awk/sed/bash to merge/concatenate data

Trying to merge some data that I have. The input would look like so: foo bar foo baz boo abc def abc ghi And I would like the output to look like: foo bar baz boo abc def ghi I have some ideas using some arrays in a shell script, but I was looking for a more elegant or quicker solution. ...

sfDoctrineGuard - how to ALWAYS join sfGuardProfile to sfGuardUser

I want to make it so that anytime the db is queried for an sfGuardUserProfile it is autmoatically joined and hydrated with its related sfGuardUser. If i was using Propel 1.2 i would normally override the doSelectStmt method of the sfGuardUserProfilePeer class to inspect the Criteria and modify it as necessary as well as modifying the hy...

select statement in C#

Where's the problem in my code ? string constr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\\Users\\Simon\\Desktop\\test5\\test5\\test5\\save.mdb"; OleDbConnection conn = new OleDbConnection(constr); string sql = "SELECT users.user_name,naziv,obroki_save.datum" + "FROM zivila JOIN obroki_save ON zivila.ID=obroki_save.ID_...

NHibernate Left Outer Join

I'm looking to create a Left outer join Nhibernate query with multiple on statements akin to this: SELECT * FROM [Database].[dbo].[Posts] p LEFT JOIN [Database].[dbo].[PostInteractions] i ON p.PostId = i.PostID_TargetPost And i.UserID_ActingUser = 202 I've been fooling around with the critera and aliases, but I haven't had a...

Java - Thread - Problem in one of the Sun's tutorial

I was reading this Sun's tutorial on Thread. I found a block of code there which I think can be replaced by a code of fewer lines. I wonder why Sun's expert programmers followed that long way when the task can be accomplished with a code of fewer lines. I am asking this question so as to know that if I am missing something that the tut...

Help with MySQL Join Statement

Hi, I just built a website and have realised that I need to have a top 3 highest rated albums.. I haven't built in something that keeps track of the ratings. Ratings are stored separately. Can someone show me how to put these together please. SELECT id, name FROM albums LIMIT 3 SELECT rating FROM ratings WHERE url=CONCAT('albums/show/...

Should I use two queries, or is there a way to JOIN this in MySQL/PHP?

Morning y'all! Basically, I'm using a table to store my main data - called 'Code' - a table called 'Tags' to store the tags for each code entry, and a table called 'code_tags' to intersect it. There's also a table called 'users' which stores information about the users who submitted each bit of code. On my homepage, I want 5 results r...

Complex Join - involving date ranges and sum...

I have two tables that I need to join... I want to join table1 and table2 on 'id' - however in table two id is not unique. I only want one value returned for table two, and this value represents the sum of a column called 'total_sold' - within a specified date range (say one month), however I want more than one date range at the same tim...

MySQL: Use CASE/ELSE value as join parameter

I'm trying to join the NAME and PHOTO from USERS table to the TRANSACTIONS table based on who is the payer or payee. It keeps telling me can't find the table this -- What am I doing wrong? SELECT `name`,`photo`,`amount`,`comment`, ( CASE `payer_id` WHEN 72823 THEN `payee_id` ELSE `payer_id` END ) AS `this` FROM `transact...

SQL Join Statement

Hi I have the following SQL SELECT statement SELECT bar_id, bar_name, town_name, advert_text FROM bar, towns, baradverts WHERE town_id = town_id_fk AND bar_id = bar_id_fk My problem is that since not every bar has an advert in table "baradverts", these bars are not coming up in the results. In other words I need a NULL for those...

MySQL JOIN with IF conditions.

Hi, I want to get some results via query simillar to: SELECT * FROM users LEFT JOIN IF (users.type = '1', 'private','company') AS details ON users.id = details.user_id WHERE users.id = 1 Any ideas? ...

subsonic 2 join on multiple columns

I want to transfer the following statement to SubSonic 2.2 SELECT b.* FROM tableA a INNER JOIN tableB b ON (a.year = b.year AND a.month = b.monath AND a.userid = b.userid); My problem is that SubSonic's SqlQuery.LeftInnerJoin() command has no overload which takes more than one column. Since any join can be rewri...

Using named_scopes on the join model of a has_many :through

Hi folks. I've been beating my head against the wall on something that on the surface should be very simple. Lets say I have the following simplified models: user.rb has_many :memberships has_many :groups, :through => :memberships membership.rb belongs_to :group belongs_to :user STATUS_CODES = {:admin => 1, :member => 2, :invi...

mysql join default value

I've been trying to use the IsNull() function to ensure that there is a value for a field. $result = mysql_query(" SELECT crawled.id,IsNull(sranking.score,0) as Score,crawled.url,crawled.title,crawled.blurb FROM crawled LEFT JOIN sranking ON crawled.id = sranking.sid WHERE crawled.body LIKE '%".$term."%' ORDER BY Score DESC LIMIT " ...

Entity Framework - Condition on one to many join (Lambda)

Hi, I have 2 entities: Customer & Account, where a customer can have multiple accounts. On the account, I have a "PlatformTypeId" field, which I need to condition on (multiple values), among other criterions. I'm using Lambda expressions, to build the query. Here's a snippet: var customerQuery = from c in context.CustomerSet.Includ...

MYSQL JOIN SELECT Statment - omit duplicated

Hi, I am tying to join the following 2 queries but I am having duplicated .... it is possible to remove duplacted fro this: ( SELECT bar_id, bar_name, town_name, bar_telephone, (subscription_type_id *2) AS subscription_type_id FROM bar, sportactivitybar, towns, subscriptiontype WHERE sport_activity_id_fk =14 AND bar_id = b...

How to have multiple tables with multiple joins

I have three tables that I need to join together and get a combination of results. I have tried using left/right joins but they don't give the desired results. For example: Table 1 - STAFF id name 1 John 2 Fred Table 2 - STAFFMOBILERIGHTS id staffid mobilerightsid rights --this table is empty-- Tabl...

Performing Inner Join for Multiple Columns in the Same Table

I have a scenario which I'm a bit stuck on. Let's say I have a survey about colors, and I have one table for the color data, and another for people's answers. tbColors color_code , color_name 1 , 'blue' 2 , 'green' 3 , 'yellow' 4 , 'red' tbAnswers answer_id , favorite_color , least_favorite_...

MySQL SELECT Statment issue

Hi, I have the following query which returns 2 tuples SELECT bar_id, bar_name, town_name, bar_telephone, subscription_type_id, pic_type FROM towns, subscriptiontype, regions, bar LEFT JOIN barpictures bp ON bar.bar_id = bp.bar_id_fk WHERE town_id = town_id_fk AND bar.test_field = 0 AND subscription_type_id = subscription_type_id_fk AND...

Basic join query understanding

I know this very silly, but can anybody help me in understanding what does this join query is doing in elabortive description? SELECT j1.* FROM jos_audittrail j1 LEFT OUTER JOIN jos_audittrail j2 ON (j1.trackid = j2.trackid AND j1.field = j2.field AND j1.changedone < j2.changedone) WHERE j1.operation = 'UPDATE' AND j1.trackid=$t_id...