alejandro52 Posted August 7, 2007 Share Posted August 7, 2007 I have two tables and i want to order them by date field.Both have the same fields.But when i use $query = 'SELECT * FROM table1,table2 ORDER BY date DESC'; it says Query failed: Column 'date' in order clause is ambiguous. Quote Link to comment https://forums.phpfreaks.com/topic/63716-order-two-tables-by-the-date-field/ Share on other sites More sharing options...
alejandro52 Posted August 7, 2007 Author Share Posted August 7, 2007 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/63716-order-two-tables-by-the-date-field/#findComment-317589 Share on other sites More sharing options...
fenway Posted August 10, 2007 Share Posted August 10, 2007 First, that's going to produce MxN rows, which is not what you want. Sound you want a UNION. Quote Link to comment https://forums.phpfreaks.com/topic/63716-order-two-tables-by-the-date-field/#findComment-320453 Share on other sites More sharing options...
teng84 Posted August 10, 2007 Share Posted August 10, 2007 it says Query failed: Column 'date' in order clause is ambiguous. i guess that error is telling you that the field also appear on the other table in your table 1 or 2 you have the same field name use an index to avoid that something like order by table1.date,table2.date Quote Link to comment https://forums.phpfreaks.com/topic/63716-order-two-tables-by-the-date-field/#findComment-320770 Share on other sites More sharing options...
fenway Posted August 20, 2007 Share Posted August 20, 2007 Actually, if you did the union, it wouldn't be ambigious anymore, because you'd have to decide if you wanted their order within the tables or overall. Quote Link to comment https://forums.phpfreaks.com/topic/63716-order-two-tables-by-the-date-field/#findComment-329181 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.