[PLUG] SQL Syntax

Russ Gilman-Hunt (YAR) gilmanhunt at comcast.net
Mon Nov 6 07:20:59 UTC 2006


On Sun, 05 Nov 2006 17:31:07 -0800
Winterbeast <winter.beast at verizon.net> wrote:

> John Jason Jordan wrote:
> 
> >I just know there are people here who dream in SQL commands. My
> >knowledge of SQL is negligible. I need to change an SQL command that
> >reads a table in an OOo Base file and displays it in a control in a
> >Writer form document. The current syntax is SELECT DISTINCT "IPA"
> >FROM "Test_Table". I need it to sort the data based on the field
> >"Number", which is also in "Test_Table". I tried appending SORT ON
> >"Number" FROM "Test_Table" but OOo puked it up. I don't have time to
> >take a course on SQL commands (I actually tried reading a book on it
> >once and found it hopeless for me). The problem is that I need to
> >deal with SQL commands only once in a blue moon; not enough to be
> >worth my time to become an expert. Can someone tell me what is the
> >secret to getting the SELECT command to sort the data when it
> >displays it in the OOo form control?
> >_______________________________________________ PLUG mailing list
> >PLUG at lists.pdxlinux.org

Given the parameters you've supplied, it sounds like you need "order
by", as in "select distinct ipa from test_table order by number."
That'd be mysql and mssql syntax. I don't know specifically about
oobase syntax. 

"Group by" is a completely different beast; that's good for things like
"select count(*), author from books order by author"; it won't do the
ordering you're asking for.

Assuming you've copied the syntax right, you'll probably want double
quotes around "number" but not around "order by." In mysql-ese, you'd
be using backticks to delineate the column names.

I don't actually _dream_ in SQL, though.

-- 
Russ Gilman-Hunt
http://www.arghwebworks.com/
gilmanhunt at comcast.net



More information about the PLUG mailing list