Reply to Re: OT - an SQL question

Your name:

Reply:


Posted by AnrDaemon on 11/11/07 12:08

Greetings, Shelly.
In reply to Your message dated Sunday, November 11, 2007, 04:29:29,

> I know [Jerry and co.] that this is off-topic, but the sql group that I
> could find online doesn't have much traffic, so here goes.

> I cam across this code:

> SELECT AnnoID, AnnoTitle,
> (SELECT EventTitle FROM mEVENTS WHERE tblANNOUNCE.AnnoLink =
> mEVENTS.EventID)
> as AnnoLink,
> date_format(AnnoDate,'%M %D %Y') as date
> FROM tblANNOUNCE
> ORDER BY AnnoDate DESC, AnnoLink, AnnoTitle

> I am having trouble reading this. Is this the same as:

> SELECT a.AnnoID, AnnoTitle, e.EventTitle as AnnoLink,
> date_format(AnnoDate,'%M %D %Y') as date
> FROM tblANNOUNCE AS a, mEVENTS AS e
> WHERE a.AnnoLink = e,EventID
> ORDER BY date DESC, AnnoLink, AnnoTitle


> In other words, do they do exactly the same thing? I can't get the former
> to run on the current version of MySQL. Apparantly (I was told) it ran on a
> later version of MySQL.


Try this (if I understand it correctly)

SELECT
a.AnnoID, a.AnnoTitle, e.EventTitle as AnnoLink, date_format(a.AnnoDate,'%M %D %Y') as date
FROM tblANNOUNCE a LEFT (or INNER) JOIN mEVENTS e ON a.AnnoLink = e.EventID
ORDER BY AnnoDate DESC, AnnoLink, AnnoTitle

Choose LEFT or INNER depends on database structure.


--
Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация