[SQL] search/replace in update

2001-06-14 Thread Gary Stainburn
Hi all, here in England OFTEL, the governing body for all things telephone recent hand another phone number dialing code change (one of many). This means that e.g. all mobile numbers that used to start 0589 now start 07889. Is there a way in SQL to update the phone number in-place? -- Gary

[SQL] pl/pgsql - code review + question

2001-07-18 Thread Gary Stainburn
|| results.mnumber; else return results.tnumber || ''-'' || results.mnumber; end if; END; ' LANGUAGE 'plpgsql'; __END__ -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested governmen

Re: [SQL] pl/pgsql - code review + question

2001-07-18 Thread Gary Stainburn
ion ''Member '' || unitno || '' not found''; return 0; end if; return results.mid; END; ' LANGUAGE 'plpgsql'; __END__ Gary On Wednesday 18 July 2001 3:10 pm, Gary Stainburn wrote: > Hi all, I've just written my first pl/pgsq

[SQL] Re: pl/pgsql - code review + question

2001-07-18 Thread Gary Stainburn
27;Member % Not Found'', unitno; > > > -Original Message- > > From: Gary Stainburn [SMTP:[EMAIL PROTECTED]] > > Sent: Wednesday, July 18, 2001 10:24 AM > > To: pgsql-sql > > Subject:Re: pl/pgsql - code review + question > > > > Okay, I&#x

[SQL] multiple lookup per row

2001-07-20 Thread Gary Stainburn
' so that it included the three phone numbers if they exist? The only solution I can think of is to write a plpgsql function to do the lookup and call that three times as part of the select, something like select *, getphone(mphone) as phone, getphone(mfax) as fax. but a p

[SQL] example of [outer] join

2001-07-20 Thread Gary Stainburn
hone(m.mmobile) as mobile, getunitno(m.mid) as munitno from members m, address a, teams t, emails e where m.madd = a.aid and m.memail = e.eid and m.mteam = t.tid; -- Gary Stainburn This email does not contain private or confidential material a

[SQL] where'd the spaces come from

2001-07-23 Thread Gary Stainburn
;) || '-' || to_char(m.mnumber,'00') as unitno from teams t, members m where m.mteam = t.tid;" unitno - SW/ 041- 03 SW/ 041- 05 NE/ 011- 06 NE/ 011- 01 NE/ 011- 03 NE/ 011- 02 NE/ 011- 10 -- Gary Stainburn This email does not contain private or

Re: [SQL] where'd the spaces come from

2001-07-23 Thread Gary Stainburn
Hi all, forget it, I've solved it. I converted the calls to: to_char(t.tnumber,'FM000') and it worked. Gary On Monday 23 July 2001 10:18 am, Gary Stainburn wrote: > Hi all, > > Can someone please explain how to remove the spaces from the results of the > query be

[SQL] Possible problems with cyclic references

2001-07-23 Thread Gary Stainburn
aight forward so far, a member must be a part of a team and a team must be in a region. My problem is that I want to set rliasson as a reference to members (mid) as the Regional Liasson Officer for each region is a member. -- Gary Stainburn This email does not contain private or confidential ma

Re: [SQL] Possible problems with cyclic references

2001-07-23 Thread Gary Stainburn
e how to set up the reference after creating the tables (it uses create triggers), and then changing/adding these lines to my create script. Your way seems much nicer. Gary On Monday 23 July 2001 3:18 pm, Jan Wieck wrote: > Gary Stainburn wrote: > > Hi all, me again. > > >

[SQL] union in subselect?

2001-07-31 Thread Gary Stainburn
ERROR: parser: parse error at or near "union" -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000

Re: [SQL] where'd the spaces come from

2001-08-03 Thread Gary Stainburn
sday 02 August 2001 4:50 pm, Bruce Momjian wrote: > Does anyone have a fix for this? > > > From: "Gary Stainburn" <[EMAIL PROTECTED]> > > > > > psql -c "select t.tregion || '/' || to_char(t.tnumber,'000') || '-'

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Gary Stainburn
plains like "ERROR: Relation > 'customers' does not exist" > when creating 'shops'. > > Someone told me I should create a third table, ok, but in this case I loose > the total > control about my logic... Do you have a suggestion ? > > Thanks a

Re: [SQL] Are circular REFERENCES possible ?

2001-08-08 Thread Gary Stainburn
n get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED]) -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed p

[SQL] create function using language SQL

2001-08-14 Thread Gary Stainburn
r,''FM000'') from teams where tid = $1; if not found then raise exception ''Team % not found'',$1; return ''''; end if; return unitno; END; ' LANGUAGE 'plpgsql'; -- Gary Stainburn

Re: [SQL] Re: Are circular REFERENCES possible ?

2001-08-14 Thread Gary Stainburn
ion ? > >> > > >> > Thanks a lot in advance ! > >> > > >> > Denis > >> > > >> > > >> > ---(end of > >> > >> broadcast)--- > >> > >>

[SQL] references definition to multi-field primary key

2002-08-16 Thread Gary Stainburn
adings ( -- daily reading per pump/nozzle prdate date not null, prpump int4 not null prnozzle int4, propen integer, prclose integer, primary key (prdate, prpump, prseq) ); I only want the insert to work if prpid matches pgpid and prnozzle matches pgnozzle. -- Gary Stainburn Th

[SQL] master-detail relationship and count

2002-11-29 Thread Gary Stainburn
key lktype indicates the link type - 'R' indicates a route entry lklid indicates the link ID. For a 'R' it is the rtid of the route entry -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government partie

Re: [SQL] master-detail relationship and count

2002-11-29 Thread Gary Stainburn
, (select r2.rtid as rid, count(lnk.lkid) as cnt from route r2,links lnk where lnk.lktype='R' and lnk.lklid = r2.rtid group by r2.rtid) as subsel where r.rtid = subsel.rid; [gary@larry gary]$ psql -d nymr On Fri, 29 Nov 2002, Gary Stainburn wrote: > > Hi folks. > > > &

Re: [SQL] master-detail relationship and count

2002-11-29 Thread Gary Stainburn
, r.rtname, subsel.cnt from route r, (select r2.rtid as rid, count(lnk.lkid) as cnt from route r2, links lnk where lnk.lktype='R' and lnk.lklid = r2.rtid group by r2.rtid) as subsel left outer join subsel on r.rtid = subsel.rid; which comes back with the error: [gary@larry gary]$ ps

[SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
hat it returns: select * from myview; sid | Name| OPS | MPD -+-+-+- 1 | Rod | | 3 2 | Jayne | 2 | 5 3 | Freddie | 3 | and if I add another row to depts, that the new row would be included? -- Gary Stainburn This email does not contain private or c

Re: [SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
a plpgsql function to dynamically create the view > you're looking for. How could a plpgsql dynamically create the view? How about a trigger from the on-update of the depts table to drop the view and then create a new one. Could it not do the same thing using outer joins. (I've done VE

Re: [SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
table to work on > -- aggregate_func ALIAS FOR $5; -- the name of the aggregate function > -- aggr_columnALIAS FOR $6; -- the aggregate column (entries to be > aggregated) > > First try: > SELECT create_pivot_report > ('sales_report2','vendor','pr

Re: [SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
ranks_record.did || ''.rdid = '' || quote_literal(ranks_record.did) > ; > END LOOP; > create_view := > create_view || join_text || '';''; > EXECUTE create_view ; > > RETURN 0; > END; > ' LANGUAGE 'plpgsql' ; > > should w

Upgrade question - was Re: [SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
On Tuesday 17 Dec 2002 2:31 pm, Tomasz Myrta wrote: > Gary Stainburn wrote: > > I found that the compile error complaining about the 'OR' was on the > > > > CREATE OR REPLACE FUNCTION > > > > line. I removed the 'OR REPLACE' and everything wo

[SQL] references table(multiple columns go here)

2002-12-18 Thread Gary Stainburn
; from stdin; 1 M 3 Charge Cleaner 2 O 3 Lock Carriages \. (I want the first row to work and the second to be rejected) -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unk

Re: [SQL] references table(multiple columns go here)

2002-12-18 Thread Gary Stainburn
Hi Tomasz, On Wednesday 18 December 2002 4:46 pm, Tomasz Myrta wrote: > Hello again > > Gary Stainburn wrote: > > Hi folks, > > > > how do I define a referene from 2 columns in 1 table to 2 columns in > > another. > > > > I have: > > > >

Re: [SQL] references table(multiple columns go here)

2002-12-18 Thread Gary Stainburn
On Wednesday 18 December 2002 4:56 pm, Gary Stainburn wrote: > Hi Tomasz, [snip] > > > create table jobtypes ( > > > jid int4 default nextval('jobs_jid_seq'::text) unique not null, > > > jdid character references ranks(rdid),

Re: [SQL] references table(multiple columns go here)

2002-12-19 Thread Gary Stainburn
Thanks for that Tom On Wednesday 18 Dec 2002 5:50 pm, Tom Lane wrote: > Gary Stainburn <[EMAIL PROTECTED]> writes: > > I've just tried this on a 7.2.1-5 system and get the same error. > > > >> create table jobtypes ( > >> jidint4 default n

Re: [SQL] references table(multiple columns go here)

2002-12-19 Thread Gary Stainburn
On Thursday 19 Dec 2002 9:58 am, Tomasz Myrta wrote: > Gary Stainburn wrote: > > That did the trick. However, I now have another problem with the > > constraint > > complaining about there not being an index to refer to. However, > > there is. > > Output

Re: [SQL] references table(multiple columns go here)

2002-12-19 Thread Gary Stainburn
On Thursday 19 Dec 2002 11:30 am, Tomasz Myrta wrote: > Gary Stainburn wrote: > > On Thursday 19 Dec 2002 9:58 am, Tomasz Myrta wrote: > > >Gary Stainburn wrote: > > >>That did the trick. However, I now have another problem with the > > >>constraint

Re: [SQL] references table(multiple columns go here)

2002-12-19 Thread Gary Stainburn
On Thursday 19 Dec 2002 3:17 pm, Tom Lane wrote: > Gary Stainburn <[EMAIL PROTECTED]> writes: > > That did the trick. However, I now have another problem with the > > constraint complaining about there not being an index to refer to. > > However, there is. &g

[SQL] Help on (sub)-select

2002-12-20 Thread Gary Stainburn
2 | 0 | 1 | 2 (1 row) nymr=# What I want to be able to do is select multiple rows and have the correct tally appear for that row. -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for

Re: [SQL] Help on (sub)-select

2002-12-20 Thread Gary Stainburn
On Friday 20 Dec 2002 10:51 am, Philip Warner wrote: > At 10:21 AM 20/12/2002 +0000, Gary Stainburn wrote: > >nymr=# select r.*, s.tally from roster r, > >nymr-# (select count(*) as tally from roster_staff where > >nymr(# rsdate = '2002-01-01' and rsgid =

[SQL] COPY fails but INSERT works

2002-12-28 Thread Gary Stainburn
ount --- 21 (1 row) nymr=# select count(*) from jobtypes; count --- 7 (1 row) nymr=# select count(*) from abilities; count --- 0 (1 row) nymr=# insert into abilities values (1, 'F', 1); INSERT 404593 1 nymr=# select count(*) from abilities; count ---

Re: [SQL] COPY fails but INSERT works

2002-12-28 Thread Gary Stainburn
On Saturday 28 December 2002 3:48 pm, Stephan Szabo wrote: > On Sat, 28 Dec 2002, Gary Stainburn wrote: > > When I create the database, I use the COPY command. The ranks and > > jobtypes are populated okay but the abilities table is empty. However, > > if I then INSERT the

[SQL] sub-select, view and sum()

2003-01-06 Thread Gary Stainburn
as rmiles from turns t left outer join staff d on t.tfitter = d.sid left outer join staff f on t.tccleaner = f.sid where r.rtid = t.tid order by tdate; ERROR: Relation 'r' does not exist -- Gary Stainburn This email does not contain priva

Re: [SQL] sub-select, view and sum()

2003-01-06 Thread Gary Stainburn
On Monday 06 January 2003 6:31 pm, Stephan Szabo wrote: > On Mon, 6 Jan 2003, Gary Stainburn wrote: > > create view turn_details as > > select t.*, d.sid as dsid, d.sname as dname, > > f.sid as fsid, f.sname as fname, > > (select sum(r.rmiles) a

Re: [SQL] returning setof in plpgsql

2003-01-21 Thread Gary Stainburn
; ---(end of broadcast)------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED]) -- Gary Stainburn This email does

Re: [SQL] CSV import

2003-01-29 Thread Gary Stainburn
tab delimited > file could be: > > #!/usr/bin/env python > > import csv > import sys > > def convert(file): > try: > f = open(file, 'r') > lines = f.readlines() > p = csv.parser() > for line in lines: > prin

Re: [SQL] efficient count/join query

2003-02-07 Thread Gary Stainburn
On Friday 07 Feb 2003 1:26 pm, Tomasz Myrta wrote: > Gary Stainburn wrote: > > On Friday 07 Feb 2003 10:48 am, Tomasz Myrta wrote: > > > > > Hi Tomasz, > > [snip] > > I understood your problem well and I just thought some idea will be enough > to continue wo

Re: [SQL] Generating serial number column

2003-02-13 Thread Gary Stainburn
yseq; select nextval('myseq'), name from tblcontact; drop sequence myseq; There may well be a way to do it without the sequence, bit I can't think of one. Gary > > > > ----- > Do you Yahoo!? > Yahoo! Shopping - Send Flowers fo

Re: [SQL] Table Pivot

2003-02-14 Thread Gary Stainburn
omail command to [EMAIL PROTECTED] so that your > message can get through to the mailing list cleanly -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulat

[SQL] efficient count/join query

2003-02-07 Thread Gary Stainburn
ly exist on the roster while many will exist on both. -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000

Re: [SQL] efficient count/join query

2003-02-07 Thread Gary Stainburn
On Friday 07 Feb 2003 10:48 am, Tomasz Myrta wrote: > Gary Stainburn wrote: > > Hi folks, > > > > I've got two tables, first a history table containing tallies for > > staff/jobs prior to going live, and second a roster table showing date, > > diagram, job

Re: [SQL] efficient count/join query

2003-02-07 Thread Gary Stainburn
On Friday 07 Feb 2003 12:09 pm, Gary Stainburn wrote: > On Friday 07 Feb 2003 10:48 am, Tomasz Myrta wrote: > > Gary Stainburn wrote: > > > Hi folks, > > > > > > I've got two tables, first a history table containing tallies for > > > staff/j

Re: [SQL] Insert multiple Rows

2003-03-04 Thread Gary Stainburn
es ('1000'); > > As single query. > > But better use COPY command or prepared statment. > > Inserts slow commonly due to indexis and foreing keys. If you use a 'prepared' insert within a transaction, would that speed things up - maybe by defering index update

[SQL] sort / limit / range problem

2003-03-05 Thread Gary Stainburn
uot; Attribute | Type | Modifier ---+---+- glid | integer | not null default nextval('glossary_glid_seq'::text) glterm| character varying(30) | not null gldesc| text | Indice

[SQL] create view error

2003-07-07 Thread Gary Stainburn
rom company) c on c.coid = lc.lcompany; ERROR: No such attribute or function ln.lnid -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2

Concat and view - Re: [SQL] create view error

2003-07-07 Thread Gary Stainburn
On Monday 07 Jul 2003 1:07 pm, Richard Huxton wrote: > On Monday 07 Jul 2003 12:40 pm, Gary Stainburn wrote: > > left outer join > > (select lnumber from lnumbers) ln on ln.lnid = l.lid and > > ^^^ ^^^ > > >

Re: Concat and view - Re: [SQL] create view error

2003-07-07 Thread Gary Stainburn
On Monday 07 Jul 2003 1:36 pm, you wrote: > On Monday 07 Jul 2003 1:07 pm, Richard Huxton wrote: > > On Monday 07 Jul 2003 12:40 pm, Gary Stainburn wrote: > > > left outer join > > > (select lnumber from lnumbers

Re: Concat and view - Re: [SQL] create view error

2003-07-07 Thread Gary Stainburn
On Monday 07 Jul 2003 3:34 pm, Richard Huxton wrote: > On Monday 07 Jul 2003 2:12 pm, Gary Stainburn wrote: > > I've managed to get the view I wanted by using sub-selects - as shown > > below, but I now have the 'lid' field showing in the resulting view three >

[SQL] numerical sort on mixed alpha/numeric data

2003-07-16 Thread Gary Stainburn
t 9 | 75014 | t 10 | 75029 | t 22 | 76079 | t 4 | 80135 | t 20 | 825 | t 18 | 901 | t 5 | 926 | f 26 | D3723 | f 15 | D5061 | t 12 | D7628 | t 25 | D9009 | t 24 | D9019 | f (38 rows) nymr=# -- Gary Stainburn This email does not con

Re: [SQL] numerical sort on mixed alpha/numeric data

2003-07-16 Thread Gary Stainburn
On Wednesday 16 July 2003 3:27 pm, Dmitry Tkach wrote: > Gary Stainburn wrote: > >Hi folks, > > > >I've got a table holding loco numbers and an id which references the locos > >table. How can I sort this table, so that numeric values appear first in > >nume

[SQL] unique value - trigger?

2003-07-17 Thread Gary Stainburn
re set to false. I'm guessing that I need to create a trigger to be actioned after an insert or update which would update set lncurrent=false where lnid not = but I can't seem to sus it put. -- Gary Stainburn This email does not contain private or confidential material as it may be

Re: [SQL] unique value - trigger?

2003-07-17 Thread Gary Stainburn
On Thursday 17 Jul 2003 3:34 pm, Dmitry Tkach wrote: > Gary Stainburn wrote: > >Hi folks, > > > >I'm back with my lnumbers table again. > > > >nymr=# \d lnumbers > > Table "lnumbers&q

Re: [SQL] sub-sel/group problem

2003-08-11 Thread Gary Stainburn
On Monday 11 August 2003 11:24 am, Gary Stainburn wrote: > Hi folks, > > I don;t know if it's cos it's Monday or what, but I can't see what's wrong > here. > > I've got two tables, turns which holds a turn number, a task, and where > appropriate a li

[SQL] sub-sel/group problem

2003-08-14 Thread Gary Stainburn
d > 0 then -#concat(r.rcid::text || ' on ' || l.lnumber::text) -# else -#r.rcid::text -# end as task -# from rides r -# left outer join loco_dets l on r.rlid = l.lid -# group by rtid -# order by rtid -# ; ERROR: Attribute r.rlid must be

Re: [SQL] URGENT!!! changing Column size

2003-10-27 Thread Gary Stainburn
can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED]) -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undis

[SQL] update from select

2003-10-29 Thread Gary Stainburn
llow field. How can I update nallowfollow from the appropriate vallowfollow flag? -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of

Re: [SQL] update from select

2003-10-29 Thread Gary Stainburn
On Wednesday 29 Oct 2003 2:58 pm, Stephan Szabo wrote: > On Wed, 29 Oct 2003, Gary Stainburn wrote: > > Hi folks, > > > > don't know if it's cos of the 17 hours I've just worked (sympathy vote > > please) but I can't get this one worked out > &g

[SQL] alias problem on join

2004-02-06 Thread Gary Stainburn
from statement group by account) as s bank-# on s.account = a.key; I get ERROR: No such attribute or function 'key' Any ideas why? Also, I'm sure I can do this more efficiently as a single select/join, but can't seem to work out why (Friday morning syndrome). Anyone give m

[SQL] where not unique

2004-03-12 Thread Gary Stainburn
've tried renaming the field to regcount in case it was a reserved word problem). -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulati

[SQL] working with unix timestamp

2004-03-16 Thread Gary Stainburn
Hi folks. I've got a last_updated field on my stock records of type timestamp. This last_updated field I get using the perl code: my $timestamp=(stat "$localcsv/VehicleStock.$data_suffix")[10]; How can I insert the integer timestamp in $timestamp into my table? -- Gary Stainbu

Re: [SQL] working with unix timestamp

2004-03-17 Thread Gary Stainburn
On Tuesday 16 March 2004 5:56 pm, Frank Finner wrote: > On Tue, 16 Mar 2004 16:54:18 +0000 Gary Stainburn > <[EMAIL PROTECTED]> sat down, thought > > long and then wrote: > > Hi folks. > > > > I've got a last_updated field on my stock records of type tim

[SQL] three-way join

2004-04-19 Thread Gary Stainburn
create view balances as select cost_cs_id, cost_cl_id, cost_css_id, count(*) as qty from cons_stock group by cost_cs_id, cost_cl_id, cost_css_id; I then have trouble joining this to the consumables and locations table to get the results I need. -- Gary Stainburn This email does not contai

Re: [SQL] three-way join

2004-04-19 Thread Gary Stainburn
id, cost_cl_id) values (1, 2, 1); create view balances as select cost_cs_id, cost_cl_id, cost_css_id, count(*) as qty from cons_stock group by cost_cs_id, cost_cl_id, cost_css_id; > > > Regards, > > Stijn Vanroye > > -

Re: [SQL] three-way join - solved

2004-04-19 Thread Gary Stainburn
On Monday 19 April 2004 4:01 pm, Gary Stainburn wrote: > On Monday 19 April 2004 3:06 pm, Stijn Vanroye wrote: > > Gary wrote: > > > Hi folks, > > > > > > here's a straight forward join that I simply can't get my head round. > > > >

[SQL] view problem - too many rows out

2004-05-12 Thread Gary Stainburn
hardware=# -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 ---(end of

solved Re: [SQL] view problem - too many rows out

2004-05-12 Thread Gary Stainburn
On Wednesday 12 May 2004 11:02 am, Gary Stainburn wrote: > Hi folks. > [snip] > create view order_summary as > select > c.cs_id, cs.count as qty, c.cs_make, c.cs_code, c.cs_type, > cst.cst_desc, c.cs_colour, > o.or_id, > o.or_supp, o.or_date

[SQL] subselect prob in view

2004-06-21 Thread Gary Stainburn
sts" psql:goole1.sql:45: ERROR: JOIN/ON clause refers to "requests", which is not part of JOIN [EMAIL PROTECTED] gary]$ which at least makes sense. -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government

Re: [SQL] subselect prob in view

2004-06-21 Thread Gary Stainburn
On Monday 21 Jun 2004 3:19 pm, Tom Lane wrote: > Gary Stainburn <[EMAIL PROTECTED]> writes: > > from requests r, users u, request_types t, > > request_states s, dealerships d, departments de, customers c > > left outer join (select co_r_id, c

Re: [SQL] subselect prob in view

2004-06-22 Thread Gary Stainburn
On Monday 21 Jun 2004 4:11 pm, Gary Stainburn wrote: > On Monday 21 Jun 2004 3:19 pm, Tom Lane wrote: > > Gary Stainburn <[EMAIL PROTECTED]> writes: > > > from requests r, users u, request_types t, > > > request_states s, dealershi

[SQL] table update using result from join

2004-10-11 Thread Gary Stainburn
# What I want is something like update requests set r_fuel=, r_c_id = 7 where r_c_id in (... -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regu

[SQL] curious delay on view/where

2004-10-28 Thread Gary Stainburn
t * from stock_available where branch != 'Doncaster' and select * from stock_available where branch != 'Leeds' which only return the equivelent of the top two (we only have Leeds and Doncaster) are les than 1 second. Anyone got any ideas of the cause, or thoughts on how I can tr

Re: [SQL] extra info - curious delay on view/where

2004-10-28 Thread Gary Stainburn
On Thursday 28 October 2004 11:16 am, Gary Stainburn wrote: > Hi folks. > > I have the following view: > > CREATE VIEW "stock_available" as > SELECT * FROM stock_details > WHERE available = true AND visible = true AND > location not in (SELECT descr FROM ign

Re: [SQL] curious delay on view/where

2004-10-28 Thread Gary Stainburn
On Thursday 28 October 2004 3:25 pm, Tom Lane wrote: > Gary Stainburn <[EMAIL PROTECTED]> writes: > > Anyone got any ideas of the cause, or thoughts on how I can trace > > the problem? > > EXPLAIN ANALYZE results for the fast and slow cases would be > interesting

[SQL] tree structure photo gallery date quiery

2004-11-16 Thread Gary Stainburn
iddleton should return 1, 2004-01-01 09:12:12 and Root should return 4, 2004-11-10 12:12:00 -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Inves

Re: [SQL] tree structure photo gallery date quiery

2004-11-16 Thread Gary Stainburn
On Tuesday 16 November 2004 1:08 pm, sad wrote: > On Tuesday 16 November 2004 14:29, Gary Stainburn wrote: > > Hi folks. > > > > I'm looking at the possibility of implementing a photo gallery for > > my web site with a tree structure > > > > How wou

[SQL] simple update from select ??

2005-03-07 Thread Gary Stainburn
of owner pp_part -- id of owned -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 ---

Re: [SQL] simple update from select ??

2005-03-07 Thread Gary Stainburn
rected version of a suggestion by Sean Davis update pieces set p_owner=piece_pieces.pp_id from piece_pieces where piece_pieces.pp_part=pieces.p_id; Under Sean's suggestion I did this inside a transaction block so I could check that it did what I wanted. -- Gary Stainburn This email does not

[SQL] order by question

2005-03-09 Thread Gary Stainburn
bumped to the top of the list, but instead appear in their correct position in the order by value part. Is it possible and if so how do I do it? -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown

Re: [SQL] order by question

2005-03-09 Thread Gary Stainburn
On Wednesday 09 March 2005 1:06 pm, you wrote: > Gary Stainburn wrote: > > Hi folks. > > > > I seem to remember somewhere being shown how to bump specific rows > > to the top of a list; something along the lines of: > > > > select c_id as key, c_des as val

[SQL] best way to swap two records (computer details)

2005-03-18 Thread Gary Stainburn
27;m not after someone to do my work for me, but a good starting point would be very much appreciated) -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regula

Re: [SQL] best way to swap two records (computer details)

2005-03-23 Thread Gary Stainburn
get a syntax error. Anyone see why? hardware=# update pieces set p_owner = (case if p_owner = 305 then 724 else 305 end) where p_owner in (305, 724); ERROR: parser: parse error at or near "p_owner" hardware=# -- Gary Stainburn This email does not contain private or confi

Re: [SQL] best way to swap two records (computer details)

2005-03-23 Thread Gary Stainburn
p_site = \'L\' where p_id = $1; > > update pieces set p_name = \'SPARE\', p_location = \'spare\', > p_site = \'L\' > where p_id = 2; > This isn't quite what I want. I want to SWAP the p_name and p_location between the two record

Re: [SQL] best way to swap two records (computer details)

2005-03-23 Thread Gary Stainburn
#x27; THEN 'A' ELSE owner END) WHERE owner IN ('A','B') > > Hello again. > > I've tried the first one but get a syntax error. Anyone see why? > > hardware=# update pieces set p_owner = (case if p_owner = 305 then > 724 else 305 end) where p_

[SQL] gone blind - can't see syntax error

2005-04-01 Thread Gary Stainburn
s d on r.r_d_id = d.d_id, left outer join departments de on r.r_de_id = de.de_id, left outer join customers c on r.r_c_id = c.c_id, left outer join comment_tallies co on r.r_id = co.r_id ORDER BY r.r_id; psql:new-view.sql:19: ERROR: parser: parse error at or near "left" -- Gary Stainburn Th

Re: [SQL] gone blind - can't see syntax error

2005-04-01 Thread Gary Stainburn
On Friday 01 April 2005 1:01 pm, you wrote: > On Friday 01 Apr 2005 5:06 pm, Gary Stainburn wrote: > > Hi folks. > > > > I've been looking at this for 10 minutes and can't see what's > > wrong. Anyone care to enlighten me. > > comma after '

[SQL] Speed up slow select - was gone blind

2005-04-01 Thread Gary Stainburn
in plates pl on r.r_plates = pl.pl_id ORDER BY r.r_id; -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000

Re: [SQL] Speed up slow select - was gone blind

2005-04-05 Thread Gary Stainburn
for the help anyway. Gary On Friday 01 Apr 2005 1:46 pm, you wrote: > Can you send the EXPLAIN ANALYZE of each? We can't really tell where > the slowdown is without that. > > On Apr 1, 2005 12:32 PM, Gary Stainburn <[EMAIL PROTECTED]> wrote: > > Hi folks. > > >

[SQL] diary constraints

2005-08-23 Thread Gary Stainburn
, one for the start date/time and one for the return date/time. How do I go about creating constraints on inserts and updates to ensure that a) the finish is after the start b) two allocations for a single vehicle don't overlap. -- Gary Stainburn This email does not contain priva

[SQL] select best price

2005-10-26 Thread Gary Stainburn
Hi folks I've got a table holding item code(cs_id), supplier a/c (co_id) , and price (cs_price). How can I select the rows containing the lowest price for each item code? I've tried various forms of min() etc and know it must be simple but I'm stumped. Gary -- Gary Stainbu

Re: [SQL] select best price

2005-10-26 Thread Gary Stainburn
On Wednesday 26 October 2005 4:21 pm, Gary Stainburn wrote: > Hi folks > > I've got a table holding item code(cs_id), supplier a/c (co_id) , and > price (cs_price). > > How can I select the rows containing the lowest price for each item > code? > > I've tried v

[SQL] Update from join

2006-07-07 Thread Gary Stainburn
270 2591 | YF06OJM | NL | NL6351 2627 | YC06SGX | ND | ND9057 1795 | YC06SGX | ND | ND9057 2634 | YB06KHT | NL | NL6450 2620 | YF06ZKD | ND | ND9236 (21 rows) -- Gary Stainburn This email does not contain private or confi

Re: [SQL] Update from join

2006-07-07 Thread Gary Stainburn
On Friday 07 July 2006 11:29, Gary Stainburn wrote: > I know this is probably a FAQ but Google etc hasn't helped. > > I have two tables, both with stock number and registration number in. > The second table always has the correct stock number, the first doesn't. > > I

Re: [SQL] SELECT substring with regex

2006-07-07 Thread Gary Stainburn
x27;) as BASE_NAME, substring('150mm LD AD Asp XR Macro','^\\d+mm (.*)$') as SUFFIX; base_name | suffix ---+ 150mm | LD AD Asp XR Macro (1 row) The brackets surround the required match -- Gary Stainburn This email does not con

[SQL] simple join is beating me

2009-07-13 Thread Gary Stainburn
4 |3 2009-07-09 | 5 |4 2009-07-08 | 12 |2 2009-07-07 | 5 |4 2009-07-06 | 2 |7 2009-07-03 | 2 |6 2009-07-02 | 7 |5 2009-07-01 | 19 |3 2009-06-30 | 20 |3 -- Gary Stainburn This emai

Re: [SQL] simple join is beating me

2009-07-13 Thread Gary Stainburn
y.o_date , orders, delivery > FROM (/* ur first query here */) ordersQuery > NATURAL RIGHT JOIN (/* ur second query goes here */) deliveryQuery > ORDER BY deliveryQuery.o_date DESC > > Tararabite, > > Oliveiros > @Allgarve > > > > 2009/7/13 Gary Stainburn >

[SQL] simple (?) join

2009-09-24 Thread Gary Stainburn
? Cheers -- Gary Stainburn Gary's Haircut 700 Please visit http://www.justgiving.com/Gary-Stainburn/ to help me raise money for Cancer Research - in return I'll have my head shaved -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscrip

  1   2   >