UNION ALL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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  

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux