pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedYour query ...
2+ messages / 1 participants
[nested] [flat]
* Your query ...
@ 1999-11-29 09:14 S S Mani <ssmani@stockholding.com>
0 siblings, 0 replies; 2+ messages in thread
From: S S Mani @ 1999-11-29 09:14 UTC (permalink / raw)
To: jt-kirkpatrick@mpsllc.com; pgsql-sql@hub.org; djackson@cpsgroup.com
Hi
Maybe your query has already been solved!
If not then pl. try it here :-
The solution given by Jackson DeJuan will work if the datatypes &
parameters of both fields are the same.
If they are not then try :-
select subnum||' ' /* The no. of spaces between the single quotes
should be equal to length of col vnum */
from subs
union
select ' '||vnum /* The no. of spaces between the single
quotes should be equal to length of col subnum */
from vend
=======================**************=======================================
> RE: [SQL] combining a single field in two tables into one column.
>
>
>
> From: "Jackson, DeJuan"
> To: JT Kirkpatrick , "'pgsql-sql@hub.org'"
> Subject: RE: [SQL] combining a single field in two tables into
> one column.
> Date: Fri, 30 Apr 1999 11:02:47 -0500
>
>
>
> try:
> select subnum from subs
> union all
> select vnum from vend;
> -DEJ
>
> > -----Original Message-----
> > From: JT Kirkpatrick [SMTP:jt-kirkpatrick@mpsllc.com]
> > Sent: Friday, April 30, 1999 10:59 AM
> > To: 'pgsql-sql@hub.org'
> > Subject: [SQL] combining a single field in two tables into one
> > column.
> >
> > i come seeking wisdom. . .
> >
> > i have two tables, one for subcontractors and another for vendors.
> subs
> > have a primary key of subnum int4, vendors a primary key of vnum
> int4. i
> > need to create a query that allows me to see a complete list of
> these
> > numbers in a single column. for instance, subnum (all begin with 9)
> has
> > values 90001, 90002, 90003 (only three records for the example), and
> vnum
> > (all begin with 2) has values 20001, 20002. i'd like my query
> result to
> > show:
> >
> > 90001
> > 90002
> > 90003
> > 20001
> > 20002
> >
> > this does NOT work: select a.subnum as z, b.vnum as z from subs a,
> vend
> > b;
> > NOR does: select a.subnum, b.vnum from subs a, vend b;
> >
> > by the way, the two tables DO NOT relate to each other (i.e., 90001
> does
> > not have anything to do with 20001). . .
> >
> > TIA, jt
>
>
^ permalink raw reply [nested|flat] 2+ messages in thread
* Your Query...
@ 1999-11-29 09:28 S S Mani <ssmani@stockholding.com>
0 siblings, 0 replies; 2+ messages in thread
From: S S Mani @ 1999-11-29 09:28 UTC (permalink / raw)
To: nuch@valigene.com; pgsql-sql@hub.org; michael.j.davis@tvguide.com
Hi
You may have already got a solution. But the most straightforward soln.
would
be :-
SELECT substr(a,1,instr(a,'_')-1)
FROM ....
< From first field to the filed before the first appearance of '_'>
Pl. confirm whether this works.
Bye
S.S.Mani
**************************************************************
RE: [SQL] substring
From: Michael J Davis <michael.j.davis@tvguide.com>
To: "'Nuchanard Chiannilkulchai'" <nuch@valigene.com>,
pgsql-sql@hub.org
Subject: RE: [SQL] substring
Date: Mon, 26 Apr 1999 14:35:16 -0500
try:
select a, substring(a, 1, position('_' in a) -1) from table_a;
I have not tested this. Not sure if the parameters to substring are
correct. Also not sure if the -1 is needed.
> -----Original Message-----
> From: Nuchanard Chiannilkulchai [SMTP:nuch@valigene.com]
> Sent: Monday, April 26, 1999 8:57 AM
> To: pgsql-sql@hub.org
> Subject: [SQL] substring
>
> Hello,
>
> How should I do my query to put a substring value in a field, in
> postgres ( I have 6.4) ?
>
> I have in table table_a
> a
> ----------------
> 98-004_c136
> P124_154
> 98-005_c171
>
> and i want to select only the text before the underscore:
>
> in sybase, this should be
> select a, substring(a,1,charindex('_',a)-1) from table_a
> a
> ---------------- ----------------
> 98-004_c136 98-004
> 98-005_c171 98-005
> P124_154 P124
>
> Thanks a lot,
> Nuch
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-11-29 09:28 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-11-29 09:14 Your query ... S S Mani <ssmani@stockholding.com>
1999-11-29 09:28 Your Query... S S Mani <ssmani@stockholding.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox