UNION ALL

UNION ALL

am 17.07.2011 06:44:01 von ron.piggott

------=_NextPart_000_003F_01CC441A.9F044F40
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable


I am trying to setup a cross reference database query for the first =
time. What I am trying to do is have a table with the structure:



CREATE TABLE IF NOT EXISTS =
`frequently_accessed_passages_of_scripture_cross_reference` (
`reference` int(5) NOT NULL AUTO_INCREMENT,
`cross_reference_article_1` int(3) NOT NULL,
`cross_reference_article_2` int(3) NOT NULL,
PRIMARY KEY (`reference`)
) ENGINE=3DMyISAM DEFAULT CHARSET=3Dlatin1 AUTO_INCREMENT=3D1 ;



If the content theme (based on auto_increment values) is listed in =
either cross_reference_article_1 OR cross_reference_article_2 then the =
counter part article will be a result so I may offer an â€=9CAlso =
available:â€=9D type link on the web page. My attempt at the UNION =
ALL query is below. I am receiving the error â€=9CEvery derived =
table must have its own aliasâ€=9D I am unsure of how to interpret =
this and correct the situation. Thanks for your help. Ron



SELECT cross_reference_article_2 FROM=20

(

SELECT `cross_reference_article_2` FROM =
`frequently_accessed_passages_of_scripture_cross_reference` WHERE =
`cross_reference_article_1` =3D 1

) UNION ALL (

SELECT `cross_reference_article_1` FROM =
`frequently_accessed_passages_of_scripture_cross_reference` WHERE =
`cross_reference_article_2` =3D 1

)

AS cross_reference_view_result


The Verse of the Day
â€=9CEncouragement from Godâ€=99s Wordâ€=9D
http://www.TheVerseOfTheDay.info
------=_NextPart_000_003F_01CC441A.9F044F40--

Re: UNION ALL

am 18.07.2011 10:59:35 von Amit Tandon

--0023545bf3381353b904a85439c4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Dear Ron

Try this

===================3D
SELECT `cross_reference_article_2`
FROM `frequently_accessed_passages_of_scripture_cross_reference`
WHERE `cross_reference_article_1` =3D 1
UNION ALL
SELECT `cross_reference_article_1`
FROM `frequently_accessed_passages_of_scripture_cross_reference`
WHERE `cross_reference_article_2` =3D 1
===================3D


I have removed the first line and the last line of your query
============
regds
amit

"The difference between fiction and reality? Fiction has to make sense."


On Sun, Jul 17, 2011 at 10:14 AM, Ron Piggott <
ron.piggott@actsministries.org> wrote:

>
> I am trying to setup a cross reference database query for the first time.
> What I am trying to do is have a table with the structure:
>
>
>
> CREATE TABLE IF NOT EXISTS
> `frequently_accessed_passages_of_scripture_cross_reference` (
> `reference` int(5) NOT NULL AUTO_INCREMENT,
> `cross_reference_article_1` int(3) NOT NULL,
> `cross_reference_article_2` int(3) NOT NULL,
> PRIMARY KEY (`reference`)
> ) ENGINE=3DMyISAM DEFAULT CHARSET=3Dlatin1 AUTO_INCREMENT=3D1 ;
>
>
>
> If the content theme (based on auto_increment values) is listed in either
> cross_reference_article_1 OR cross_reference_article_2 then the counter p=
art
> article will be a result so I may offer an â€=9CAlso available:â€=
=9D type link on
> the web page. My attempt at the UNION ALL query is below. I am receivin=
g
> the error â€=9CEvery derived table must have its own aliasâ€=9D =
I am unsure of how
> to interpret this and correct the situation. Thanks for your help. Ron
>
>
>
> SELECT cross_reference_article_2 FROM
>
> (
>
> SELECT `cross_reference_article_2` FROM
> `frequently_accessed_passages_of_scripture_cross_reference` WHERE
> `cross_reference_article_1` =3D 1
>
> ) UNION ALL (
>
> SELECT `cross_reference_article_1` FROM
> `frequently_accessed_passages_of_scripture_cross_reference` WHERE
> `cross_reference_article_2` =3D 1
>
> )
>
> AS cross_reference_view_result
>
>
> The Verse of the Day
> â€=9CEncouragement from Godâ€=99s Wordâ€=9D
> http://www.TheVerseOfTheDay.info

--0023545bf3381353b904a85439c4--