List:General Discussion« Previous MessageNext Message »
From:mathias fatene Date:April 25 2005 8:01pm
Subject:RE: Query question
View as plain text  
Hi,
Why my answer doesn't answer his question. Did you heared about his
comment. Let him do it.
If you're confused, i can explain more one-to-many relashionships. 

If you think about joins and want absolutely add them, this is the error
generating performance problems asked along all RDMBS, especially with
mysql (DBMS till now).

Best Regards
--------------------
Mathias FATENE
 
Hope that helps
*This not an official mysql support answer
 


-----Original Message-----
From: SGreen@stripped [mailto:SGreen@stripped] 
Sent: lundi 25 avril 2005 21:44
To: mathias fatene
Cc: 'Jeff McKeon'; mysql@stripped
Subject: RE: Query question


"mathias fatene" <mfatene@stripped> wrote on 04/25/2005 03:19:33 PM:

> Hi,
> You can do something like that :
> 
> 
> mysql> select * from son;
> +------+
> | a    |
> +------+
> |    1 |
> |    2 |
> |    3 |
> +------+
> 3 rows in set (0.02 sec)
> mysql> select * from mother;
> +------+------+
> | a    | b    |
> +------+------+
> |    1 | a    |
> |    1 | b    |
> |    2 | a    |
> |    2 | c    |
> |    3 | a    |
> |    3 | b    |
> |    3 | c    |
> |    3 | d    |
> +------+------+
> 8 rows in set (0.00 sec)
> 
> mysql> select a,max(b) from mother
>     -> group by a;
> +------+--------+
> | a    | max(b) |
> +------+--------+
> |    1 | b      |
> |    2 | c      |
> |    3 | d      |
> +------+--------+
> 3 rows in set (0.00 sec)
> 
> The max will be used with your datetime column. The "son" table can 
> not be used, or joined to the mother.
> 
> 
> Best Regards
> --------------------
> Mathias FATENE
> 
> Hope that helps
> *This not an official mysql support answer
> 
> 
> 
> -----Original Message-----
> From: Jeff McKeon [mailto:jmckeon@stripped]
> Sent: lundi 25 avril 2005 21:01
> To: mysql@stripped
> Subject: Query question
> 
> 
> I have a table that contains records that link back to a main talbe in

> a many to one configuration linked by table1.id = table2.parentid
> 
> Table1 (one)
> Table2 (many)
> 
> I want to pull the latest records from table2 for each record in 
> table1 where certain criteria applie.
> 
> So, if record 100 in table1 links to 5 corresponding records in 
> table2, I want to pull the latest record from table2 where 
> table2.parentid = 100 and table2.user not like 'john'
> 
> There is a datestamp field in table2.
> 
> I just can't figure out how to do this.
> 
> Thanks,
> 
> Jeff
> 

I think I am decent at what I do and that confused even me. I am totally

baffled at what SQL concept you were trying to illustrate.

How did you _help_ the OP?  The question that started this thread is an 
example of a common class of SQL problems and several solutions exist. 
Your "solution" neither answered his query nor was it explained to the 
point that made it comprehendable. Please, please try to be less
confusing 
(especially when responding to newbies).

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Thread
Query questionJeff McKeon25 Apr
  • Re: Query questionSGreen25 Apr
  • RE: Query questionmathias fatene25 Apr
    • RE: Query questionSGreen25 Apr
      • RE: Query questionmathias fatene25 Apr
  • Re: Query questionPeter Brawley25 Apr
    • RE: Query questionmathias fatene25 Apr
RE: Query questionJeff McKeon25 Apr
  • Re: Query questionPeter Brawley25 Apr
    • RE: Query questionmathias fatene25 Apr
      • Re: Query questionPeter Brawley25 Apr
      • RE: Query questionSGreen25 Apr
        • RE: Query questionmathias fatene26 Apr
          • Re: Query questionMartijn Tonies26 Apr
            • RE: Query questionmathias fatene26 Apr
              • Re: Query questionChris Ramsay26 Apr
                • Re: Query questionmfatene26 Apr
  • Re: Query questionPeter Brawley25 Apr
  • RE: Query questionSGreen25 Apr
RE: Query questionJeff McKeon25 Apr
  • Re: Query questionPeter Brawley25 Apr
RE: Query questionJeff McKeon25 Apr
  • Re: Query questionPeter Brawley25 Apr
RE: Query questionJeff McKeon25 Apr