Re: Distinct Records Based On One Field - fixed

2004-06-21 Thread Michael Stassen
I think you still did it wrong, assuming the first column is IDs, but no 
matter.  How do you determine which row from Table2 is "the last record 
inserted with that number."?

Michael
PhistucK wrote:
I'm posting it again coz I did it all wrong. so here it is again:
I got a little problem.
I want to show distinct results based on only one field of the record,
field1.
Here's an example. I want to show records from Table1 & Table2 and each
number in field1\tfield1 must be output only once (unique), the last record
inserted with that number.
If my tables are:
Table1:
   field1 field2 field3
1 5Five   Five
2 4Four   Four
3 3Three Three
4 6Six  Six
5 8Eight  Eight
6 9Nine   Nine
Table2:
   tfield1 tfield2
1 5One
2 4Bla
3 5Blah
4 3Bluh
5 5Bla bla
5 6Bl.a
7 8B.La
8 9Lba
9 3LAb
I want to output this:
Output
field1 field2 field3  tfield2
1 4Four   Four   Bla
2 5FiveFive   Bla bla
3 6Six  Six Bl.a
4 8Eight  Eight  B.La
5 9Nine   Nine   Lba
6 3Three Three LAb
 Is there a way to do that? without making another table everytime I insert
records to the second? I mean, by an sql command?
 Thanks in advance.
PhistucK

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Distinct Records Based On One Field - fixed

2004-06-21 Thread PhistucK
I'm posting it again coz I did it all wrong. so here it is again:
I got a little problem.
I want to show distinct results based on only one field of the record,
field1.
Here's an example. I want to show records from Table1 & Table2 and each
number in field1\tfield1 must be output only once (unique), the last record
inserted with that number.
If my tables are:
Table1:
   field1 field2 field3
1 5Five   Five
2 4Four   Four
3 3Three Three
4 6Six  Six
5 8Eight  Eight
6 9Nine   Nine
Table2:
   tfield1 tfield2
1 5One
2 4Bla
3 5Blah
4 3Bluh
5 5Bla bla
5 6Bl.a
7 8B.La
8 9Lba
9 3LAb
I want to output this:
Output
field1 field2 field3  tfield2
1 4Four   Four   Bla
2 5FiveFive   Bla bla
3 6Six  Six Bl.a
4 8Eight  Eight  B.La
5 9Nine   Nine   Lba
6 3Three Three LAb

 Is there a way to do that? without making another table everytime I insert
records to the second? I mean, by an sql command?

 Thanks in advance.

PhistucK

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]