[SQL] Updating column to link one table to another

2004-12-17 Thread Mark Collette
I have two tables, with a many to one relationship. Table InfrequentTable - timestamp ts - int infrequentId (newly added key) Table FrequentTable(Many FrequentTable entries per one InfrequentTable entry) - timestamp ts - int infrequentId (newly added column) The

[SQL] get branches & childs from database

2004-12-17 Thread Marcus Krause
Hello newsgroup! I'm trying to build up a menu by sending ONE query to database. Afterwards the result is used by PEAR::HTML_Menu get a html-structered menu. db-structure of gallery: ++---+--+--++---+ | id | title | date | root | parent | level | ++---+--+-

Re: [SQL] can't get the order I want after inserting new rows

2004-12-17 Thread Richard Huxton
Marcus Claesson wrote: Hi Richard, Just looking at the start of your output, you are missing some rows (a/1/1) and have replaced others (a/2/1 isn't in your data). Yes, that's exactly it. There's no mistake. The only column I need to update is 'full', by giving every row a new 'full', based on i

Re: [SQL] Table History

2004-12-17 Thread RobertD . Stewart
Here is a example of a trigger function CREATE OR REPLACE FUNCTION public.ipinfo_trg() RETURNS trigger AS 'DECLARE dhcpvarchar:=\'DHCP\'; rtype varchar:=\'RAS\'; BEGIN if NEW.ipaddress != dhcp then if OLD.ipaddress != dhcp then if OLD.atype != rtype then

Re: [SQL] Table History

2004-12-17 Thread John DeSoi
On Dec 17, 2004, at 1:23 AM, Richard Sydney-Smith wrote: I expect this has been done MANY times and I wonder if a general purpose trigger exists or if not then can someone point me to an example set of triggers? I'm not aware of a "general purpose" trigger for this. If you just want some extra

Re: [SQL] sql can i substitute

2004-12-17 Thread Bruno Wolff III
On Fri, Dec 17, 2004 at 18:22:48 +0530, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > On Friday 17 December 2004 06:12 pm, D'Arcy J.M. Cain wrote: > > > An alternative to Andreas' suggestion would be to create a simple lookup > > table and join them. This is good if the real life example can g

Re: [SQL] sql can i substitute

2004-12-17 Thread Bruno Wolff III
On Fri, Dec 17, 2004 at 16:55:45 +0530, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > hi > > table: > > name varchar(10) > fruit integer > > i want to write an sql statement like this: > > select fruit from table > > which should return 'good' if fruit = 1 and 'bad' if fruit =2 and 'rotten'

Re: [SQL] can't get the order I want after inserting new rows

2004-12-17 Thread Marcus Claesson
Hi Richard, > Just looking at the start of your output, you are missing some rows > (a/1/1) and have replaced others (a/2/1 isn't in your data). Yes, that's exactly it. There's no mistake. The only column I need to update is 'full', by giving every row a new 'full', based on its 'score'. The tri

Re: [despammed] [SQL] sql can i substitute

2004-12-17 Thread Achilleus Mantzios
O Kenneth Gonsalves έγραψε στις Dec 17, 2004 : > On Friday 17 December 2004 05:54 pm, Andreas Kretschmer wrote: > > > Yes, simple: > > > > test=# select name, case > > test-# when fruit = 1 then 'good' > > test-# when fruit = 2 then 'bad' > > test-# when fruit = 3 then 'rotten' end as fruit from

Re: [despammed] [SQL] sql can i substitute

2004-12-17 Thread Kenneth Gonsalves
On Friday 17 December 2004 05:54 pm, Andreas Kretschmer wrote: > Yes, simple: > > test=# select name, case > test-# when fruit = 1 then 'good' > test-# when fruit = 2 then 'bad' > test-# when fruit = 3 then 'rotten' end as fruit from fruit; can one do the same thing for an 'insert' statement? k

Re: [SQL] sql can i substitute

2004-12-17 Thread Kenneth Gonsalves
On Friday 17 December 2004 06:12 pm, D'Arcy J.M. Cain wrote: > An alternative to Andreas' suggestion would be to create a simple lookup > table and join them. This is good if the real life example can get > larger and/or the list can change and you don't want to modify code > every time it does.

Re: [SQL] sql can i substitute

2004-12-17 Thread D'Arcy J.M. Cain
On Fri, 17 Dec 2004 16:55:45 +0530 Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > i want to write an sql statement like this: > > select fruit from table > > which should return 'good' if fruit = 1 and 'bad' if fruit =2 and > 'rotten' if fruit =3 An alternative to Andreas' suggestion would be to

Re: [SQL] can't get the order I want after inserting new rows

2004-12-17 Thread Richard Huxton
Marcus Claesson wrote: Hi! I have a problem with getting the order I want on a table after new rows have been inserted. I try to simplify it...: In other words, I have this old table: SELECT * from table ORDER BY full,part; namefullpartscore --- --- - a 1

Re: [despammed] [SQL] sql can i substitute

2004-12-17 Thread Andreas Kretschmer
am 17.12.2004, um 17:48:15 +0530 mailte Kenneth Gonsalves folgendes: > > thanks - opened up a whole new world for me. One more thing, the values come > under the column 'case', can i avoid having the column 'case' and get the > 'good', 'bad' and 'rotten' under the column 'fruit'? Yes, simple:

Re: [despammed] [SQL] sql can i substitute

2004-12-17 Thread Kenneth Gonsalves
On Friday 17 December 2004 05:15 pm, Andreas Kretschmer wrote: > test=# select * from fruit; > name | fruit > +--- > Apple | 1 > Banana | 2 > Cherry | 3 > (3 Zeilen) > > > test=# select name, fruit, case > test-# when fruit = 1 then 'good' > test-# when fruit = 2 th

Re: [despammed] [SQL] sql can i substitute

2004-12-17 Thread Andreas Kretschmer
am 17.12.2004, um 16:55:45 +0530 mailte Kenneth Gonsalves folgendes: > hi > > table: > > name varchar(10) > fruit integer > > i want to write an sql statement like this: > > select fruit from table > > which should return 'good' if fruit = 1 and 'bad' if fruit =2 and 'rotten' if > fruit =3 >

[SQL] sql can i substitute

2004-12-17 Thread Kenneth Gonsalves
hi table: name varchar(10) fruit integer i want to write an sql statement like this: select fruit from table which should return 'good' if fruit = 1 and 'bad' if fruit =2 and 'rotten' if fruit =3 can it be done? kg ---(end of broadcast)--- TI

[SQL] can't get the order I want after inserting new rows

2004-12-17 Thread Marcus Claesson
Hi! I have a problem with getting the order I want on a table after new rows have been inserted. I try to simplify it...: I want to have a one-to-one relationship between 'name' and 'full'. Every 'name' (or'full') have one or more 'parts'. The higher the 'score' the lower the 'full', but for my p