Re: [SQL] Join question

2008-08-19 Thread Edward W. Rouse
PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Edward W. Rouse Sent: Tuesday, August 19, 2008 2:04 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] Join question I was trying to do something like this, but couldn't get it to work. I am trying to follow the example you provided, but

Re: [SQL] Join question

2008-08-19 Thread Edward W. Rouse
EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lennin Caro Sent: Tuesday, August 19, 2008 11:59 AM To: 'Daniel Hernandez'; pgsql-sql@postgresql.org; Edward W. Rouse Subject: Re: [SQL] Join question --- On Tue, 8/19/08, Edward W. Rouse <[EMAIL PROTECTED]> wrote:

Re: [SQL] Join question

2008-08-19 Thread Lennin Caro
--- On Tue, 8/19/08, Edward W. Rouse <[EMAIL PROTECTED]> wrote: > From: Edward W. Rouse <[EMAIL PROTECTED]> > Subject: Re: [SQL] Join question > To: "'Daniel Hernandez'" <[EMAIL PROTECTED]>, pgsql-sql@postgresql.org > Date: Tuesday, August 19,

Re: [SQL] Join question

2008-08-19 Thread Oliveiros Cristina
To: pgsql-sql@postgresql.org Sent: Tuesday, August 19, 2008 2:36 PM Subject: Re: [SQL] Join question I thought of that, but it does violate table constraints. Edward W. Rouse From: Oliveiros Cristina [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2008 2:00 PM To:

Re: [SQL] Join question

2008-08-19 Thread Edward W. Rouse
I have tried left, right outer and inner. Edward W. Rouse From: Daniel Hernandez [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2008 12:30 PM To: pgsql-sql@postgresql.org; [EMAIL PROTECTED] Subject: Re: [SQL] Join question have you tried a right Join? Daniel Hernndez. San Diego

Re: [SQL] Join question

2008-08-19 Thread Edward W. Rouse
I thought of that, but it does violate table constraints. Edward W. Rouse From: Oliveiros Cristina [mailto:[EMAIL PROTECTED] Sent: Monday, August 18, 2008 2:00 PM To: pgsql-sql@postgresql.org; [EMAIL PROTECTED] Subject: Re: [SQL] Join question I don't understand your count(

Re: [SQL] Join question

2008-08-18 Thread Oliveiros Cristina
Original Message - From: Daniel Hernandez To: pgsql-sql@postgresql.org ; [EMAIL PROTECTED] Sent: Monday, August 18, 2008 5:30 PM Subject: Re: [SQL] Join question have you tried a right Join? Daniel Hernndez. San Diego, CA. "The more you learn, the more you earn&qu

Re: [SQL] Join question

2008-08-18 Thread Daniel Hernandez
have you tried a right Join?Daniel Hernndez.San Diego, CA."The more you learn, the more you earn".Fax: (808) 442-0427-Original Message-From: "Edward W. Rouse" [EMAIL PROTECTED]: 08/15/2008 09:48 AMTo: [EMAIL PROTECTED]: Re: [SQL] Join question I have 2

Re: [SQL] Join question

2008-08-15 Thread Steve Midgley
At 12:20 PM 8/15/2008, [EMAIL PROTECTED] wrote: Date: Fri, 15 Aug 2008 13:46:14 -0400 From: "Edward W. Rouse" <[EMAIL PROTECTED]> To: Subject: Re: Join question Message-ID: <[EMAIL PROTECTED]> I did try that, but I can't get both the values from table a with no entries in table b and the value

Re: [SQL] Join question

2008-08-15 Thread Edward W. Rouse
Of Richard Broersma Sent: Friday, August 15, 2008 1:10 PM To: Edward W. Rouse Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] Join question On Fri, Aug 15, 2008 at 9:48 AM, Edward W. Rouse <[EMAIL PROTECTED]> wrote: > The problem is I also have to include > items from table b with that have

Re: [SQL] Join question

2008-08-15 Thread Richard Broersma
On Fri, Aug 15, 2008 at 9:48 AM, Edward W. Rouse <[EMAIL PROTECTED]> wrote: > The problem is I also have to include > items from table b with that have a null user. There are some other criteria > as well that are simple where clause filters. So as an example: instead of left join try FULL OUTER

Re: [SQL] Join question

2008-08-15 Thread Edward W. Rouse
: Friday, August 15, 2008 12:48 PM To: pgsql-sql@postgresql.org Subject: [SQL] Join question I have 2 tables, both have a user column. I am currently using a left join from table a to table b because I need to show all users from table a even those not having an entry in table b. The problem is

[SQL] Join question

2008-08-15 Thread Edward W. Rouse
I have 2 tables, both have a user column. I am currently using a left join from table a to table b because I need to show all users from table a even those not having an entry in table b. The problem is I also have to include items from table b with that have a null user. There are some other crite

Re: [SQL] Join question

2007-08-21 Thread Michael Glaesemann
On Aug 21, 2007, at 12:48 , [EMAIL PROTECTED] wrote: SELECT a.x, max(b.x) FROM a, b, c WHERE a.a_id = c.a_id AND b.b_id = c.b_id GROUP by a.x; Shouldn't affect performance, but another way to write this which you may find more readable is to list your join conditions with the joins rather

Re: [SQL] Join question

2007-08-21 Thread Richard Broersma Jr
oops... I meant "DISTINCT ON ( a_id )" --- Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > SELECT a.x, b.x > FROM ( SELECT DISTINCT ON ( a_id ) a_id, b_id ^^ >FROM c ) AS c( a_id, b_id ) > INNER JOIN a > ON c.a_id = a.id > INNER J

Re: [SQL] Join question

2007-08-21 Thread Richard Broersma Jr
--- [EMAIL PROTECTED] wrote: > create table c ( >a_id int, >b_id int > ); > > I am doing a query like this: > > SELECT a.x, max(b.x) FROM a, b, c WHERE a.a_id = c.a_id AND b.b_id = > c.b_id GROUP by a.x; > > I only need to get one row from b for each row in a, and it really > doesn't ma

[SQL] Join question

2007-08-21 Thread tyrrill_ed
Hey All, I have a query I'm trying to speed up, and I was hoping someone could help me. I have a three tables a and b hold data, and c just references between a and b: create table a ( a_id int, x int ); create table b ( b_id int, x int ); create table c ( a_id int, b_id int

Re: [SQL] Join question

2007-07-26 Thread Paul Lambert
Phillip Smith wrote: Whoops, I forgot the JOIN conditions! Fixed below -Original Message- From: Phillip Smith [mailto:[EMAIL PROTECTED] Sent: Friday, 27 July 2007 11:47 To: 'pgsql-sql@postgresql.org' Subject: RE: [SQL] Join question This might give you a starting

Re: [SQL] Join question

2007-07-26 Thread Phillip Smith
Whoops, I forgot the JOIN conditions! Fixed below -Original Message- From: Phillip Smith [mailto:[EMAIL PROTECTED] Sent: Friday, 27 July 2007 11:47 To: 'pgsql-sql@postgresql.org' Subject: RE: [SQL] Join question This might give you a starting point if I understand you

Re: [SQL] Join question

2007-07-26 Thread Phillip Smith
This might give you a starting point if I understand you correctly... SELECT h.invoice_number, h.customer, l.item, l.amount FROMlines AS l JOINheaders AS h UNION SELECT h.invoice_number, h.customer, s.item, s.amount FROMsundries AS

[SQL] Join question

2007-07-26 Thread Paul Lambert
I have a database in a parts sales environment that I am having a little difficulty with a join query - trying to figure out which way to join things. I have a parts_invoice_header table, containing the header record for each invoice. I have a parts_invoice_lines table, containing the parts de

Re: [SQL] JOIN question with multiple records

2006-01-05 Thread Richard Huxton
Scott, Casey wrote: I have 2 tables. One containing information about servers, and the other containing information about IP addresses. E.G. Server table: namemac mac2 - SERVER1 00:0d:56:ba:ad:92 SE

[SQL] JOIN question with multiple records

2006-01-04 Thread Scott, Casey
I have 2 tables. One containing information about servers, and the other containing information about IP addresses. E.G. Server table: namemac mac2 - SERVER1 00:0d:56:ba:ad:92 SERVER2 00:0d:56

Re: [SQL] join question

2002-11-28 Thread Manfred Koizar
On Wed, 27 Nov 2002 09:37:07 -0800, Nathan Young <[EMAIL PROTECTED]> wrote: >OK, that works great, but I was told that I should avoid sub-selects when >possible for performance reasons. >> >> select member.memberId, member.name from member left outer join >> (select * from payment where yearPaid=

Re: [SQL] join question

2002-11-27 Thread Nathan Young
OK, that works great, but I was told that I should avoid sub-selects when possible for performance reasons. Also, I used so much mental energy trying to find a solution that would do either task using a join that I would be very curious if anyone had a solution. The setup: >> I have a table wi

Re: [SQL] join question

2002-11-26 Thread Stephan Szabo
On Fri, 22 Nov 2002, Nathan Young wrote: > Hi all. > > I have a table with members and a table with payments. Each payment is > related to a member by memberID and each payment has (among other things) a > year paid. > > I can create a join to find a list of members who have paid for a given yea

[SQL] join question

2002-11-26 Thread Nathan Young
Hi all. I have a table with members and a table with payments. Each payment is related to a member by memberID and each payment has (among other things) a year paid. I can create a join to find a list of members who have paid for a given year (2002 in this case): select member.memberID,membe

Re: [SQL] join question

2002-10-18 Thread Jean-Luc Lachance
I think you meant: select profile.name from profile,attribute where ( profile.id = attribute.containerId) and ( profile.state =' 1020811' or ( attribute.name = 'marketsegment' and attribute.value = '1020704'); > select profile.name from profile,attribute where > ((profile.state='1020811') or (

Re: [SQL] join question

2002-10-18 Thread Stephan Szabo
On Fri, 18 Oct 2002, Frank Morton wrote: > For the SQL gurus, a query where I'm not getting the expected > results. Trying to write it using sql compatible with both postgres > and mysql. > > There are two tables: > > table = profile > int id > char name > > table = attribute > int id > int contai

[SQL] join question

2002-10-18 Thread Frank Morton
For the SQL gurus, a query where I'm not getting the expected results. Trying to write it using sql compatible with both postgres and mysql.   There are two tables:   table = profile int id char name   table = attribute int id int containerId char name char value   Multiple attribute rows corre

[SQL] Join Question

2002-09-17 Thread Robert J. Sanford, Jr.
My office is working on a fantasy football database and, unfortunately, I have been tagged as the DBA. I'm a bit weak on set theory but I'm trying. Right now I am trying to calculate up game scores into the database rather than running through code to do that. A baseline of my schema is that: + E

Re: [SQL] join question - requesting for a simple C program where it can INSERT data into database as reference

2002-06-13 Thread joo
My problem is, i am writing a simple retrieval program using C, to retrieve a set of records from database. Then i'll make certain calculation based on the data that i have retrieved and write it on a new database. I have follow the sample program to do the retrieval and it works. But i don't see

Re: [SQL] join question - three tables, two with foreign keys to the first

2002-06-13 Thread Dmitri Colebatch
> why do you expect nulls? probably because my sql is extremely rusty (o: > SELECT ... FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col2; > > returns nulls for the b-columns in the select list, if you have a row > in t1 with a value t1.col1, that does not appear as col2 in any row of > t2. In your exam

Re: [SQL] join question - three tables, two with foreign keys to

2002-06-13 Thread Stephan Szabo
On Fri, 14 Jun 2002, Dmitri Colebatch wrote: > maybe just to qualify, I get this: > > select emp.name, lv.from_date, lv.to_date, pay.amount > from employee as emp > left join employee_leave as lv on emp.id = lv.employee_id > left join employee_pay as pay on emp.id = pay.employee_id > where emp.i

Re: [SQL] join question - three tables, two with foreign keys to the first

2002-06-13 Thread Manfred Koizar
On Fri, 14 Jun 2002 00:13:22 +1000, "Dmitri Colebatch" <[EMAIL PROTECTED]> wrote: >select emp.name, lv.from_date, lv.to_date, pay.amount >from employee as emp >left outer join employee_leave as lv on emp.id = lv.employee_id >left outer join employee_pay as pay on emp.id = pay.employee_id >where em

Re: [SQL] join question - three tables, two with foreign keys to the first

2002-06-13 Thread Dmitri Colebatch
- From: "Dmitri Colebatch" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, June 14, 2002 12:13 AM Subject: [SQL] join question - three tables, two with foreign keys to the first > hey all, > > here's my situation. three tables: > > create ta