Re: [SQL] question on SELECT

2000-12-19 Thread Prasanth A. Kumar
Howard Hiew <[EMAIL PROTECTED]> writes: > Hi, > I would like to know what is the sql statement that list all the tables > name. > > For example in Oracle, > 'SELECT TABLE_NAME from ALL_TABLES where owner="Oracle" '; > > What is the statement for Postgres? > Thank you > > Best Regards, > Howard

Re: [SQL] Tree structure table normalization problem (do I need atrigger?)

2000-12-19 Thread Tulassay Zsolt
On Tue, 19 Dec 2000, Frank Joerdens wrote: > In a recent thread (How to represent a tree-structure in a relational > database) I asked how to do a tree structure in SQL, and got lots of > suggestions (thanks!), of which I chose the one below: > > create table Category ( > CategoryID int4

[SQL] replace??

2000-12-19 Thread Bruno Boettcher
hello, i have the following problem: i have in php an array structure with user-prefs that have to be stored onto DB actually i look up if the corresponding entry exists (comparing user-name and field-name) if yes i update, if no i insert this isn't very appealing, but i couldn't find a

Re: [SQL] replace??

2000-12-19 Thread Brett W. McCoy
On Tue, 19 Dec 2000, Bruno Boettcher wrote: > actually i look up if the corresponding entry exists (comparing > user-name and field-name) if yes i update, if no i insert > > this isn't very appealing, but i couldn't find another way yet to make > this shorter... > > would be nice if something

Re: [SQL] Tree structure table normalization problem (do I need atrigger?)

2000-12-19 Thread Frank Joerdens
Tulassay Zsolt wrote: [ . . . ] > The SQL stuff of that nested set structure is fairly easy, I wrote some > quick'n'dirty plpgsql functions that will do inserts, updates, deletes > from the tree, display level number etc. What scared me about it in particular was one scenario where you try to del

Re: [SQL] Tree structure table normalization problem (do I need atrigger?)

2000-12-19 Thread Frank Joerdens
> Michael Ansley wrote: > > Hi, Frank, > > This is exactly why there are alternative solutions for trees. The mechanism that >you > are using traded input speed for 'queryability', and this is where you start to run >into > problems. Either you need to store redundant information (i.e.: the

[SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread juerg . rietmann
Hello there I have a question regarding a SQL statement. When I execute (and that's what I need) SELECT Zylinder.Z_durch_soll, Zylinder.Z_id, Zylinder.Z_durch_ist, ((Zylinder.Z_durch_soll+0.12) - Zylinder.Z_durch_ist) AS durchmesserdelta, (Zylinder.Z_durch_soll+0.12) AS effektiv FROM Auftrag,Zy

Re: [SQL] Tree structure table normalization problem (do I need atrigger?)

2000-12-19 Thread Neil Thompson
On Tue, 19 Dec 2000, Frank Joerdens wrote: > Tulassay Zsolt wrote: > [ . . . ] > > I can send it to you if you like (please allow a few days since I > > have several exams at the university this week). > > Sure, I'd like to have a look at it! I'd like to have a look at it as well, please. Che

Re: [SQL] Bounds checking on an alias

2000-12-19 Thread Alessio Bragadini
[EMAIL PROTECTED] wrote: > SELECT DISTINCT tbl_restaurant.restaurant, > tbl_restaurant_location.postal_code, tbl_restaurant_location.latitude > AS latitude, tbl_restaurant_location.longitude AS longitude, distance > (49.24894, -122.90419, latitude, longitude) AS distance FROM > tbl_restaurant, tb

Re: [SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread Stephan Szabo
On Tue, 19 Dec 2000 [EMAIL PROTECTED] wrote: > Hello there > > I have a question regarding a SQL statement. > > When I execute (and that's what I need) > > SELECT Zylinder.Z_durch_soll, Zylinder.Z_id, Zylinder.Z_durch_ist, > ((Zylinder.Z_durch_soll+0.12) - Zylinder.Z_durch_ist) AS durchmesserd

Re: [SQL] Tree structure table normalization problem (do I need a trigger?)

2000-12-19 Thread Josh Berkus
Frank, > However, I have > a problem now > which seems non-trivial: I am at some point in the tree, > say 3 nodes > down from the root, but I don't know where I am exactly > (across which > nodes would I travel along the shortest path to the top?) > and would like > to find out. This is, again, n

Re: [SQL] Tree structure table normalization problem (do I need atrigger?)

2000-12-19 Thread Tulassay Zsolt
On Tue, 19 Dec 2000, Frank Joerdens wrote: > Tulassay Zsolt wrote: > [ . . . ] > > The SQL stuff of that nested set structure is fairly easy, I wrote some > > quick'n'dirty plpgsql functions that will do inserts, updates, deletes > > from the tree, display level number etc. > > What scared me

Re: [SQL] Tree structure table normalization problem (do I need a trigger?)

2000-12-19 Thread Frank Joerdens
Josh Berkus wrote: [ . . . ] > This is exactly why my model includes a "Level" column. I looked at your post from a few days ago again; you did indeed explain about the level column. I missed that somehow and had to reinvent the wheel . . . > > This means > > you need a loop control structure wh

[SQL] Create table doesn't work in plpgsql

2000-12-19 Thread Volker Paul
Hi, can I do some table manipulation in plpgsql? Look at only the "create table" line and the error message: create function plural (text) returns text as ' begin create table tmp (num int4); return $1 || ''s''; end;' language 'plpgsql'; select plural('test'); CREATE ERROR: cop

Re: [SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread Jie Liang
I hope it may help: 1. if you use group clause in a select stmt, the select list must be agregate function such as sum(field),count(field), max(field)..., cannot use field. 2. for field have NULL field, should use field IS NULL, = NULL will give you wrong result! Jie LIANG Internet Products In

Re: [SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread Jie Liang
Hope it helps: 1. If you use GROUP, the select list should sum|count|max ..., no single field. 2. If you use NULL, the condition should be field IS [NOT] NULL, = NULL will give the wrong answer. Jie LIANG Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 O

[SQL] substring ..

2000-12-19 Thread Jeff MacDonald
hi folks.. i want to do this to a datetime field.. select foo from table where substr(datefoo,1,11) = '2000-12-14'; it returns no results yet.. select substr(datefoo,1,11) does return some values that say 2000-12-14 any clues ? Jeff MacDonald, ---

Re: [SQL] question on SELECT

2000-12-19 Thread Jie Liang
use: \dt -- all tables \dv -- all views \df -- all functions ... Jie LIANG Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 [EMAIL PROTECTED] www.ipinc.com On 19 Dec 2000, Prasanth A. Kumar wrote: > Howard Hiew <[EMAIL PROTECTED]> wri

[SQL] group by: properly?

2000-12-19 Thread Emils Klotins
Hello, I must confess I have always been a bit baffled by the GROUP BY, therefore I would appreciate if you could tell me if there's a better way: I have the table "items": id | integer | not null default nextval('items_id_seq'::text) seller_id| integer | not null materi

RE: [SQL] substring ..

2000-12-19 Thread Francis Solomon
Hi Jeff, '2000-12-14' is only 10 chars long. You're asking for an 11-char long substring to match a 10-char ... not going to happen! You can see this better if you do something like this ... select '@' || substr(datefoo,1,11) || '@' from table; ... and you'll get results like: @2000-12-14 @ S

Re: [SQL] substring ..

2000-12-19 Thread Stephan Szabo
On Tue, 19 Dec 2000, Jeff MacDonald wrote: > hi folks.. > > i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; > > it returns no results yet.. > > select substr(datefoo,1,11) does return some values that say > 2000-12-14 > > any clues

Re: [SQL] substring ..

2000-12-19 Thread Josh Berkus
Jeff, > i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; > > it returns no results yet.. > > select substr(datefoo,1,11) does return some values that say > 2000-12-14 Well, for one it's not a string, it's a datetime field. WHy are y

Re: [SQL] substring ..

2000-12-19 Thread Joel Burton
> i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; > > it returns no results yet.. > > select substr(datefoo,1,11) does return some values that say > 2000-12-14 Ummm... because '2000-12-14' is a ten-character, not eleven character lo

Re: [SQL] substring ..

2000-12-19 Thread Tulio Oliveira
Jeff MacDonald wrote: > > hi folks.. > > i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; > > it returns no results yet.. > > select substr(datefoo,1,11) does return some values that say > 2000-12-14 > > any clues ? > > Jeff MacDon

Re: [SQL] substring ..

2000-12-19 Thread Robert B. Easter
Hehe, here is my tests with this: ctntest2=# SELECT create_date FROM users; create_date 2000-08-29 13:01:53-04 2000-08-27 20:04:41-04 2000-08-27 21:24:28-04 2000-08-30 09:51:16-04 2000-07-25 23:14:08-04 2000-07-25 23:14:08-04 2000-09-01 02:53:02-04 2000-07-2

Re: [SQL] substring ..

2000-12-19 Thread Karel Zak
On Tue, 19 Dec 2000, Jeff MacDonald wrote: > hi folks.. > > i want to do this to a datetime field.. > > select foo from table where substr(datefoo,1,11) = '2000-12-14'; And why not to_char()? Karel