Not quite.  We're not looking for a left join or natural left join.
I'm not sure MySQL or any database can even do this, it may have to be 
done (rather unattractively) on the API side.
The data in the two tables aren't tied by ID, and shouldn't mix w/ each 
other at all.
To do this, all we've been able to come up with is to use the API (PHP 
in our case) to make 2 queries, copy them into the same array,
and sort the array by timestamp.  However the API's array sort isn't the 
quickest thing ever coded, and the SQL level is where we'd like
to do the sorting.

To clarify, I'll give an example of what we are trying to do:

daily_notes:
note_id    user_num    timestamp    note
1                1                    1                Hello
2                1                    2                Goodbye
3                2                    31               Blah

project_notes:
note_id    user_num    timestamp    note
1                2                    1                Working hard
2                1                    5                Watching others 
work hard


We'd like a query that would return daily_notes #1 and #2 and 
project_notes #2.
However, like I said earlier, I'm not sure SQL can do this.  This list 
is kind of a last resort before defaulting on letting the API sort it 
out after the 2 queries.

Ken wrote:

>Sounds like a left join, maybe even a "natural join", which I haven't tried yet.
>
>select message
>from project left join daily on project.uid = daily.uid
>order by timestamp
>
>Check manual for syntax.
>
>Or am I missing something?
>
>- Ken
>[EMAIL PROTECTED]
>
>At 05:47 PM 9/6/01 -0700, Michael Garvin wrote:
>
>>Ok, we just can't seem to find a solution for this problem.  Thought I'd post it up 
>to see if anyone has any input.
>>
>>Say you have 2 tables project_notes and daily_notes.
>>Each table has a timestamp, and a user_id.
>>Is there any way, in one query, to select all messages from both tables that were 
>entered by a given user_id and
>>sort by timestamp?
>>
>>This isn't the first time this problem has come up here where I work, another 
>application of this solution (if it exists) would be to query
>>different tables representing different realms on our radius servers to get a total 
>usage summary across our network for a given user.
>>




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to