Looks like the theoretical standard.. which can be extended as follows:
select -
from -
where -
[and -]
group by -
having -
order by -
Only gets ugly on multiple table joins, where the select and from lines are
long
Donncha O Caoimh said
>>> I used to just write my SQL queries like normal test, overflowing each
> line with no regard for readability.
> Then I started ordering the columns of inserts and selects
> one above the
> other, now, I have the following format which i discovered from a mail
> to the MySQL list..
> $query = "SELECT hits
> FROM gr_logs
> WHERE user_id ='".$this->user."'
> AND broker_id ='".$this->broker."'
> AND symbol ='".$this->symbol."'";
>> All rather neat and tidy, makes it easy to read. How do the
> rest of you
> write your SQL?
> (I don't care if I don't have to put the $this->var variables
> outside of
> the quote, it's easier in the long-run with more complicated
> structures..)
>> Donncha.
>> _______________________________________________
> Webdev mailing list
>Webdev at linux.ie>http://www.linux.ie/mailman/listinfo/webdev>
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!