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. 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? 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. 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 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. 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
Archived
This topic is now archived and is closed to further replies.