----- Original Message ----- 
From: <[EMAIL PROTECTED]>

>> Bob wrote:
> <snipped some message here>
> 
>> You need to group your selects together, also it is a good idea to name
>> your tables in the join to keep from ambiguity issues though not
>> mandatory. See below:
>>
>> SELECT *,
>> DATE_FORMAT(h.msg_id,'%W %D %M %Y at %l:%i %p') AS msgdate,
>> DATE_FORMAT(r.reply_date,'%W %D %M %Y at %l:%i %p') AS myreplydate
>> FROM familyhistory h
>> LEFT JOIN familyreplies r ON h.msg_id = r.reply_id
>> ORDER BY msg_id DESC
>> LIMIT $pageoffset, $maxperpage
> 
> Hi William,
> That did the trick.
> I take your point about naming tables to stop clashes in a join.
> I deliberately made all items different in an attempt to eliminate this, as 
> I was struggling with it.
> As you say, it's not mandatory if no conflicting names, but good practice.
> 
> Hadn't come across using a table alias (as your example) but just found it 
> in my books.
> Saves a lot of typing.
> 
> I'm trying to learn the correct way, so I will leave the table alias in.
> Thanks, Bob.
> 
> ------------------------------
> 
> No need to make the field names unique in different tables. Just specify 
> them in sql
> 
> SELECT users.user_id FROM users ....


Hi Rob,
I understand it better now. My main problem was not having all my selects 
together.
Found table name aliases are a real help, and it makes it more readable.
It was my first join <grin>.

As you can probably guess, I'm writing my own message board just as an exercise.
I know there are plenty available, but it gives me a goal in the learning 
process.
Thanks, Bob.


Reply via email to