Re: [SQL] inner join and limit

2010-06-06 Thread msi77
Hi, Some ways to do that: http://www.sql-ex.ru/help/select16.php > Hi list, > I have two table that are so represented: > t1: > id int primary key > ... other > t2: > id int primary key > t1id int fk(t1.id) > somedate date > ... other > data t1: > 1 | abcde > 2 | fghi > data t2: > 1 | 1 | 2010-05-

Re: [SQL] inner join and limit

2010-06-03 Thread Harald Fuchs
In article <4bfd5bc0.90...@unipex.it>, Michele Petrazzo - Unipex writes: > Hi list, > I have two table that are so represented: > t1: > id int primary key > ... other > t2: > id int primary key > t1id int fk(t1.id) > somedate date > ... other > data t1: > 1 | abcde > 2 | fghi > data t2: > 1 |

Re: [SQL] inner join and limit

2010-05-26 Thread Rolando Edwards
I found a good solution. drop table if exists t3; drop table if exists t2; drop table if exists t1; create table t1 ( id int primary key, title varchar(10) ); insert into t1 values (1,'abcde'),(2,'fghi'); create table t2 (id int primary key,t1id int not null references t1 (id) ,somedate date); in

Re: [SQL] inner join and limit

2010-05-26 Thread Tim Landscheidt
Michele Petrazzo - Unipex wrote: > I have two table that are so represented: > t1: > id int primary key > ... other > t2: > id int primary key > t1id int fk(t1.id) > somedate date > ... other > data t1: > 1 | abcde > 2 | fghi > data t2: > 1 | 1 | 2010-05-23 > 2 | 1 | 2010-05-24 > 3 | 1 | 2010-

Re: [SQL] inner join and limit

2010-05-26 Thread Luigi Antognini
Hello Here a suggestion for your problem. SELECT a.id AS t1_id, d.id AS t2_id, d.somedate AS t2_somedate FROM t1 a JOIN ( SELECT id, t1id, somedate FROM t2 b WHERE (t1id, somedate) IN ( SELECT t1id, somedate FROM t2 c WHERE c.t1id = b.t1id ORDE

Re: [SQL] inner join and limit

2010-05-26 Thread Rolando Edwards
I can only see a LIMIT 1 possible. If someone can come up with LIMIT N on this one, please let us all know. rolando=# drop table if exists t2; DROP TABLE rolando=# drop table if exists t1; DROP TABLE rolando=# create table t1 ( id int primary key, title varchar(10) ); NOTICE: CREATE TABLE / PRIM