dbTalk Databases Forums  

SQL multiple statements?

comp.databases.ms-access comp.databases.ms-access


Discuss SQL multiple statements? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Annie D via AccessMonster.com
 
Posts: n/a

Default SQL multiple statements? - 09-16-2005 , 05:14 AM






Hi,

Is it possible to use multiple statements in SQL?? (I’ve never used it before)
:

I have one query that i'm working with, The statements I want to use are as
below, they all work individually, but not together, Access help is as much
use as a chocolate fireguard in this case! any suggestions or explainations
would be gratefully appreciated:

Thank you.

SELECT DATA_START_DATE, Left([DATA_START_DATE],4) AS DATA_START_DATE_year,
Mid([DATA_START_DATE],5,2) AS DATA_START_DATE_month, Mid([DATA_START_DATE],7,
2) AS DATA_START_DATE_day, DateSerial([DATA_START_DATE_year],
[DATA_START_DATE_month],[DATA_START_DATE_day]) AS DATA_START_DATE_date FROM
5F3_HEORG_IL_RF__20000101_0000_V01


SELECT DATA_END_DATE, Left([DATA_END_DATE],4) AS DATA_END_DATE_year, Mid(
[DATA_END_DATE],5,2) AS DATA_END_DATE_month, Mid([DATA_END_DATE],11,2) AS
DATA_END_DATE_day, DateSerial([DATA_END_DATE_year],[DATA_END_DATE_month],
[DATA_END_DATE_day]) AS DATA_END_DATE_date FROM
5F3_HEORG_IL_RF__20000101_0000_V01


SELECT START_DATE, Left([START_DATE],4) AS START_DATE_year, Mid([START_DATE],
5,2) AS START_DATE_month, Mid([START_DATE],11,2) AS START_DATE_day,
DateSerial([START_DATE_year],[START_DATE_month],[START_DATE_day]) AS
START_DATE_date FROM 5F3_HEORG_IL_RF__20000101_0000_V01


SELECT END_DTTM, Left([END_DTTM],4) AS END_DTTM_year, Mid([END_DTTM],5,2) AS
END_DTTM_month, Mid([END_DTTM],11,2) AS END_DTTM_day, DateSerial(
[END_DTTM_year],[END_DTTM_month],[END_DTTM_day]) AS END_DTTM_date FROM
5F3_HEORG_IL_RF__20000101_0000_V01


SELECT CREATE_DTTM, Left([CREATE_DTTM],4) AS CREATE_DTTM_year, Mid(
[CREATE_DTTM],5,2) AS CREATE_DTTM_month, Mid([CREATE_DTTM],11,2) AS
CREATE_DTTM_day, DateSerial([CREATE_DTTM_year],[CREATE_DTTM_month],
[CREATE_DTTM_day]) AS CREATE_DTTM_date FROM
5F3_HEORG_IL_RF__20000101_0000_V01


SELECT MODIF_DATE, Left([MODIF_DATE],4) AS MODIF_DATE_year, Mid([MODIF_DATE],
5,2) AS MODIF_DATE_month, Mid([MODIF_DATE],11,2) AS MODIF_DATE_day,
DateSerial([MODIF_DATE_year],[MODIF_DATE_month],[MODIF_DATE_day]) AS
MODIF_DATE_date FROM 5F3_HEORG_IL_RF__20000101_0000_V01


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200509/1

Reply With Quote
  #2  
Old   
Keith
 
Posts: n/a

Default Re: SQL multiple statements? - 09-16-2005 , 05:44 AM






"Annie D via AccessMonster.com" <forum (AT) AccessMonster (DOT) com> wrote

Quote:
Hi,

Is it possible to use multiple statements in SQL?? (I've never used it
before)
:

I have one query that i'm working with, The statements I want to use are
as
below, they all work individually, but not together, Access help is as
much
use as a chocolate fireguard in this case! any suggestions or
explainations
would be gratefully appreciated:

I think what you're after is a union query but for this to work the fields
in each branch of the query have to match. Search the help for "union
query" for more info.

Regards,
Keith.
www.keithwilby.com




Reply With Quote
  #3  
Old   
Brian Wilson
 
Posts: n/a

Default Re: SQL multiple statements? - 09-16-2005 , 07:57 AM



"Keith" <keith.wilby (AT) baeAWAYWITHITsystems (DOT) com> wrote

Quote:
"Annie D via AccessMonster.com" <forum (AT) AccessMonster (DOT) com> wrote in message
news:54719413D464C (AT) AccessMonster (DOT) com...
Hi,

Is it possible to use multiple statements in SQL?? (I've never used it
before)
:

I have one query that i'm working with, The statements I want to use are
as
below, they all work individually, but not together, Access help is as
much
use as a chocolate fireguard in this case! any suggestions or
explainations
would be gratefully appreciated:

I think what you're after is a union query but for this to work the fields
in each branch of the query have to match. Search the help for "union
query" for more info.

Regards,
Keith.
www.keithwilby.com

As you probably know, union queries are usually used to get rows from
different places and "stack the results on top of each other". E.g. you
have tables tblTeacher and tblPupil and you want a list of all people
regardless of whether they are teacher or pupil

SELECT TeacherName AS PersonName FROM tblTeacher
UNION
SELECT PupilName AS PersonName FROM tblPupil

With the case in question, each separate select query returns all records
from the same table each time, so I'm not sure she wants the records
"stacked on top of each other". Perhaps all fields from all queries is
required but I would have thought that was straight forward. Or perhaps the
question is can Access work like SQL Server where one stored procedure could
have multiple select statements returning multiple recordsets.
Perhaps the OP would like to clarify.






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.