and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
$sql1="SELECT 'administration', ad_id, ad_date, ad_title, ad_short_desc
FROM cgi_admin
UNION SELECT 'activities', act_id, act_date, act_title, short_desc
FROM cgi_activities
works great but the problem comes up when i want to sort by a specific column - if i add "sort by" to any of the querys then it will sort them only in that query itself -- if i sort by ad_date it will show all the results from the first select and then start over for the second select. how do i sort them all?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
$sql1="SELECT 'administration', ad_id, ad_date, ad_title, ad_short_desc
FROM cgi_admin
UNION SELECT 'activities', act_id, act_date, act_title, short_desc
FROM cgi_activities
works great but the problem comes up when i want to sort by a specific column - if i add "sort by" to any of the querys then it will sort them only in that query itself -- if i sort by ad_date it will show all the results from the first select and then start over for the second select. how do i sort them all?
SELECT * FROM (
SELECT 'administration' as type, ad_id as id, ad_date as my_date, ad_title as title, ad_short_desc as description
FROM cgi_admin
UNION SELECT 'activities', act_id, act_date, act_title, short_desc
FROM cgi_activities
) ORDER BY my_date;
thanks so much for your help. i tried that exact query and got this error message:
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 'administration' AS type , ad_id AS id , ad_date AS my_d
any idea why?
thats pretty weird, i'm using PhpMyAdmin shouldn't it have up to date support? anyway if it doesn't any other ideas on my original question?
update: this is what i got from mysql_get_server_info(): 4.0.27-max-log
yshaf13 wrote:thats pretty weird, i'm using PhpMyAdmin shouldn't it have up to date support? anyway if it doesn't any other ideas on my original question?
update: this is what i got from mysql_get_server_info(): 4.0.27-max-log
Please note phpMyAdmin is not MySQL; the two should not be confused. MySQL is the actual RDBMS server that allows you to connect from a client, such as 'mysql', 'mysqldump', PHP, etc. phpMyAdmin is simply a PHP application that uses one of PHP's built in methods to connect to MySQL.
Your MySQL server is unfortunately unable to perform subqueries (4.1+ as Everah mentioned). 5.0 is the current production version, although most hosting outfits still offer 4.1. If you're stuck with 4.0 I would suggest looking for a new host.