SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: union of 4 queries
-
Mar 10, 2009, 09:31 #1
- Join Date
- Aug 2004
- Location
- Swindon
- Posts
- 304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
union of 4 queries
how would i union 4 queries together? ie something like
Code:SELECT Title, CAST(PUBLISHEDDATE as date) as publisheddate, rsslink, content FROM RSS1 UNION SELECT Title, CAST(PUBLISHEDDATE as date) as publisheddate, rsslink, content FROM RSS2 UNION SELECT Title, CAST(PUBLISHEDDATE as date) as publisheddate, rsslink, content FROM RSS3 UNION SELECT Title, CAST(PUBLISHEDDATE as date) as publisheddate, rsslink, content FROM RSS4 UNION
btw i realise the above wont work - its just to illustrate my idea
-
Mar 10, 2009, 09:51 #2Guido - Community Team Leader
The Votes Are In: The Winners of the 2013 Community Awards are...
Blog - Free Flash Slideshow Widget
-
Mar 10, 2009, 09:58 #3
- Join Date
- Aug 2004
- Location
- Swindon
- Posts
- 304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
lol - excellent, that was easy
Ok, to mix it up a bit, is it easy to select the latest from each of the 4 feeds, then combine it?
so i would end up with 4 results?
edit - thanks btw
-
Mar 10, 2009, 10:01 #4
Do a
Code:ORDER BY PUBLISHEDDATE DESC LIMIT 1
Guido - Community Team Leader
The Votes Are In: The Winners of the 2013 Community Awards are...
Blog - Free Flash Slideshow Widget
-
Mar 10, 2009, 10:18 #5
- Join Date
- Aug 2004
- Location
- Swindon
- Posts
- 304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ah crud, cant use limit, dammit. This is a coldfusion thing. nothing is easy
-
Mar 10, 2009, 10:28 #6
I don't know anything about coldfusion, but why can't you use LIMIT? Aren't you using MySQL?
Guido - Community Team Leader
The Votes Are In: The Winners of the 2013 Community Awards are...
Blog - Free Flash Slideshow Widget
-
Mar 10, 2009, 12:47 #7
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
i really have to ask this: why do you have 4 separate tables? they look like they all have the same kind of data!!!
-
Mar 10, 2009, 13:14 #8
- Join Date
- Aug 2004
- Location
- Swindon
- Posts
- 304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
its for a "query of queries" thing in coldfusion, so its not in essance 4 tables....
QofQ uses a subset of mysql in which limit is not included
-
Mar 10, 2009, 14:28 #9
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
okay thanks
by the way, coldfusion's query-of-query does not use a "subset of mysql"
-
Mar 11, 2009, 02:52 #10
- Join Date
- Aug 2004
- Location
- Swindon
- Posts
- 304
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok, it uses a subset of SQL
When you query an existing query, you can use a subset of SQL statements, functions, and operators.
Bookmarks