| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: SQL Help |
From: Ellen K. Oh, that's a simple UNION: SELECT a.emp_no FROM Finance UNION SELECT b.emp_no FROM Sales On Fri, 09 May 2003 08:29:33 +0100, Chris Robinson wrote in message : >hehe - yeh, I might as well give an example anyways (just incase someone here knows >of a more efficient way to do it). Take tables A and B below, each table contains >the same kind of information (i.e. a field called emp_no). > >Table A - Finance Table B - Sales > emp_no emp_no > 0001 0004 > 0002 0005 > 0003 0006 > >Ideally I'd like a query that pulls the information from table 1 and table 2 into >one column. So, the ideal result would be a list of all employee numbers: > >Query Result > emp_no > 0001 > 0002 > 0003 > 0004 > 0005 > 0006 > >It doesn't look to hard but selecting each field from each table just gives you a >result that has 2 columns - one contains the emp_no's from table A and the other, >the emp_no's from table B. > >Chris. > >Ellen K wrote: > >> Not sure how I missed your original post, sorry. >> >> Glad you accomplished what you wanted, because from your description I can't >> figure out what that was!!!! >> >> > From: Chris Robinson >> > Thanks for the tip - it didn't like it though :o( Instead I created a macro >> >that wipes a table, adds one set of values to it and then appends the next set >> > - I then query this table. >> > Everything else just merged the two fields inito one which wasn't what I was >> > after. >> > Thanks anyway, >> > Chris. >> > Adam Flinton wrote: >> >> Union possibly union all. >> >> >> >> I think Access'es SQL supports Union but I haven't a copy to hand.... >> >> >> >> If you want just unique records then do a select distinct >> >> >> >> Adam >> >> >> >> Chris Robinson wrote: >> >> > Is this the right place to post this? I hope so. >> >> > >> >> > I'm writing a database in Access 2000 atm and I was hoping to get a bit >> >> > of an SQL pointer. It's probably an easy one although I can't think of >> >> > a way to do it in a query atm. >> >> > >> >> > I have two tables (X and Y), each with a column that contains a 4 digit >> >> > code. I want to create a query that brings the data from these TWO >> >> > columns into ONE column. I don't want to merge the data - it's more a >> >> > case of take the values from table X and append the values from table Y. >> >> > >> >> > The nearest I got was: >> >> > >> >> > SELECT (xTBL.code & yTBL.code) AS code_list >> >> > FROM xTBL, yTBL; >> >> > >> >> > This actually does merge the fields of the two tables though (i.e. both >> >> > field values in one field) I tried GROUPBY's and SELECT DISTINCT but my >> >> > SQL skills aren't exactly up there. The next thing I'm thinking of is >> >> > doing, if this can't be done this way, is an add query (to a table) for >> >> > the xTBL field and then an append query to the same table for the yTBL >> >> > field. >> >> > >> >> > Thanks in advance, >> >> > Chris. >> >> > >> >> > >> >> > --- BBBS/NT v4.01 Flag-4* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/1.45) SEEN-BY: 633/267 270 @PATH: 379/1 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.