Your query ...
От | S S Mani |
---|---|
Тема | Your query ... |
Дата | |
Msg-id | 3842440B.2AA9E04F@stockholding.com обсуждение исходный текст |
Список | pgsql-sql |
Hi <br />Maybe your query has already been solved! <br />If not then pl. try it here :- <br />The solution given by JacksonDeJuan will work if the datatypes & parameters of both fields are the same. <br />If they are not then try :-<p>select subnum||' ' /* The no. of spaces between the single quotes should be equal to length of col vnum */ <br/>from subs <br />union <br />select ' '||vnum /* The no. of spaces between the single quotes should be equalto length of col subnum */ <br />from vend <br /> =======================**************=======================================<br /> <blockquote type="CITE">RE: [SQL]combining a single field in two tables into one column.<br /><br /><br /><br /> From: "Jackson, DeJuan" <br /> To: JT Kirkpatrick , "'pgsql-sql@hub.org'" <br /> Subject: RE: [SQL] combining a single field in two tablesinto one column. <br /> Date: Fri, 30 Apr 1999 11:02:47 -0500 <br /><br /><br /><br /> try:<br /> select subnumfrom subs<br /> union all<br /> select vnum from vend;<br /> -DEJ<br /><br /> > -----Original Message-----<br/> > From: JT Kirkpatrick [SMTP:jt-kirkpatrick@mpsllc.com]<br /> > Sent: Friday, April 30, 1999 10:59AM<br /> > To: 'pgsql-sql@hub.org'<br /> > Subject: [SQL] combining a single field in two tables into one<br/> > column.<br /> > <br /> > i come seeking wisdom. . .<br /> > <br /> > i have two tables, one forsubcontractors and another for vendors. subs <br /> > have a primary key of subnum int4, vendors a primary key ofvnum int4. i <br /> > need to create a query that allows me to see a complete list of these <br /> > numbers ina single column. for instance, subnum (all begin with 9) has <br /> > values 90001, 90002, 90003 (only three recordsfor the example), and vnum <br /> > (all begin with 2) has values 20001, 20002. i'd like my query result to <br/> > show:<br /> > <br /> > 90001<br /> > 90002<br /> > 90003<br /> > 20001<br /> > 20002<br />> <br /> > this does NOT work: select a.subnum as z, b.vnum as z from subs a, vend<br /> > b;<br /> > NORdoes: select a.subnum, b.vnum from subs a, vend b;<br /> > <br /> > by the way, the two tables DO NOT relate toeach other (i.e., 90001 does <br /> > not have anything to do with 20001). . .<br /> > <br /> > TIA, jt<br /><br/><br /></blockquote>
В списке pgsql-sql по дате отправления: