By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,866 Members | 1,765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,866 IT Pros & Developers. It's quick & easy.

SQL multiple statements?

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Annie D via AccessMonster.com" <fo***@AccessMonster.com> wrote in message
news:54***********@AccessMonster.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
Nov 13 '05 #2

P: n/a
"Keith" <ke*********@baeAWAYWITHITsystems.com> wrote in message
news:43**********@glkas0286.greenlnk.net...
"Annie D via AccessMonster.com" <fo***@AccessMonster.com> wrote in message
news:54***********@AccessMonster.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.


Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.