Re: [SQL] Can i force deletion of dependent rows?

2010-02-12 Thread Tim Landscheidt
Shruthi A wrote: > I have 2 tables (A and B) where the table B has a foreign key reference to > table A. Like this: > create table A (x int primary key); > create table B (y int primary key, z int references A (x) ); > As you can see, i've not specified any further 'on delete' clause to the >

[SQL] Can i force deletion of dependent rows?

2010-02-12 Thread Shruthi A
Hello, I have 2 tables (A and B) where the table B has a foreign key reference to table A. Like this: create table A (x int primary key); create table B (y int primary key, z int references A (x) ); As you can see, i've not specified any further 'on delete' clause to the foreign key constraint

Re: [SQL] complex join question

2010-02-12 Thread Tim Landscheidt
Louis-David Mitterrand wrote: > Here is my schema: > cruise_line -> ship(id_line) -> cruise_type(id_ship) -> cruise(id_cruise_type) > -> price(id_cruise, id_currency) <- currency (USD,GBP,EUR,CAD) > (a 'cruise' is a 'cruise_type' + a date) > I am trying to display a count of cruise's for

[SQL] complex join question

2010-02-12 Thread Louis-David Mitterrand
Hi, Here is my schema: cruise_line -> ship(id_line) -> cruise_type(id_ship) -> cruise(id_cruise_type) -> price(id_cruise, id_currency) <- currency (USD,GBP,EUR,CAD) (a 'cruise' is a 'cruise_type' + a date) I am trying to display a count of cruise's for each ship and each currency even

Re: [SQL] "left join" not working?

2010-02-12 Thread Oliveiros C,
Yes, because your WHERE is something that comes after the operation of the LEFT JOIN, in practice, defeating the purpose you intented. On your second query the p.id_line = 1 doesn't do that because it is part of the LEFT JOIN itself.. HTH Best, Oliveiros d'Azevedo Cristina - Original Mes

Re: [SQL] "left join" not working?

2010-02-12 Thread Louis-David Mitterrand
On Fri, Feb 12, 2010 at 11:35:02AM -, Oliveiros C, wrote: > My first guess is that > NULL fails the condition on your WHERE clause, > p.id_line = 1 > > So your WHERE clause introduces an additional level of filtering > that filters out the NULLs coming from the LEFT JOIN... So, if I understan

Re: [SQL] "left join" not working?

2010-02-12 Thread msi77
> where p.id_line=1 this filters rows after join was applied. Try this select c.id_currency,max(p.modified_on) from currency c left join price_line p using (id_currency) where (p.id_line=1 or p.id_line is null) group by c.id_currency; > Hi, > This query: > select c.id_currency,max(p.modif

Re: [SQL] "left join" not working?

2010-02-12 Thread Oliveiros C,
My first guess is that NULL fails the condition on your WHERE clause, p.id_line = 1 So your WHERE clause introduces an additional level of filtering that filters out the NULLs coming from the LEFT JOIN... Didn't do any tests, it's just a guess... Best, Oliveiros - Original Message -

[SQL] "left join" not working?

2010-02-12 Thread Louis-David Mitterrand
Hi, This query: select c.id_currency,max(p.modified_on) from currency c left join price_line p using (id_currency) where p.id_line=1 group by c.id_currency; doesn't list all c.id_currency's, only those with a price_line. However this one does: select c.id_currency,max(p.modified_on) from curren