Re: [PHP-DB] UNION ALL
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.pigg...@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
[PHP-DB] UNION ALL
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
Re: [PHP-DB] UNION ALL query help
Your union creates a table called rss_feed. This table has 4 columns (page_title, last_update, article and reference) from which you try to select the unknown column 'title'. So basicly, exactly what your db is telling you. If it doesn't make sense, strip the outer select and see what your subquery returns. That should make it more clear. regards On Sat, 2010-04-24 at 20:50 -0400, Ron Piggott wrote: I am received the error message: Unknown column 'title' in 'field list' from the query below. I am not understanding what I have done wrong. The goal of the query is with for a RSS feed determining the 15 most current articles. Ron SELECT title, content_date, content, reference FROM ( ( SELECT `page_title`, `last_update`, 'article', `reference` FROM `user_pages` WHERE `include_in_highlights` =1 ORDER BY `last_update` DESC LIMIT 15 ) UNION ALL ( SELECT `blog`.`entry_title`, `blog`.`entry_date`, `blog`.`entry`, `blog`.`reference` FROM blog WHERE blog_owners_reference =1 ORDER BY blog.entry_date DESC, blog.reference DESC LIMIT 15 ) ) AS rss_feed ORDER BY rss_feed.content_date DESC LIMIT 15 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] UNION ALL query help
I am received the error message: Unknown column 'title' in 'field list' from the query below. I am not understanding what I have done wrong. The goal of the query is with for a RSS feed determining the 15 most current articles. Ron SELECT title, content_date, content, reference FROM ( ( SELECT `page_title`, `last_update`, 'article', `reference` FROM `user_pages` WHERE `include_in_highlights` =1 ORDER BY `last_update` DESC LIMIT 15 ) UNION ALL ( SELECT `blog`.`entry_title`, `blog`.`entry_date`, `blog`.`entry`, `blog`.`reference` FROM blog WHERE blog_owners_reference =1 ORDER BY blog.entry_date DESC, blog.reference DESC LIMIT 15 ) ) AS rss_feed ORDER BY rss_feed.content_date DESC LIMIT 15 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php