Re: UNION ALL

From: Date: Mon, 18 Jul 2011 08:59:35 +0000
Subject: Re: UNION ALL
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-47930@lists.php.net to get a copy of this message
Dear Ron Try this =================== SELECT cross_reference_article_2 FROM frequently_accessed_passages_of_scripture_cross_reference WHERE cross_reference_article_1 = 1 UNION ALL SELECT cross_reference_article_1 FROM frequently_accessed_passages_of_scripture_cross_reference WHERE cross_reference_article_2 = 1 =================== 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=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > > > 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 “Also available:” type link on > the web page. My attempt at the UNION ALL query is below. I am receiving > the error “Every derived table must have its own alias” 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 = 1 > > ) UNION ALL ( > > SELECT cross_reference_article_1 FROM > frequently_accessed_passages_of_scripture_cross_reference WHERE > cross_reference_article_2 = 1 > > ) > > AS cross_reference_view_result > > > The Verse of the Day > “Encouragement from God’s Word” > http://www.TheVerseOfTheDay.info

« previous php.db (#47930) next »