I have two tables thread, respuesta and there is a one to many relationship between them thread(one) respuesta(many). both of these tables have threadid and fecha, fecha is datetime. What I want to do is order the table thread by date "fecha" (very simple), but ordered by both fecha from respuesta and fecha from thread where respueta.thredid=thread.threadid threadid primary key for thread respid primary key for respuesta
ok, try this query:
SELECT T.threadid, T.fecha, R.respid, R.fecha FROM thread AS T, respuesta AS R WHERE T.threadid=R.respid ORDER BY T.fecha, R.fecha;
You can add or remove fields from the list after the SELECT and before the FROM.