var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: using subquery in mysql (was "Help get this query working")
I have a table called 'myTable' which consists of two fields, field_id (int) and time (DateTime). I have a query which works fine in SqlServer which won't work in MySql.
The query is supposed to display a list of times with a ranking. When I run the above query I get an error
select *, (select count(*) + 1 from myTable t where t.time < m.time) as Rank from myTable m order by Rank desc
Can anyone help me?
#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 count(*) + 1 from myTable t whe
you cannot use subqueries in mysql unless you are on at least version4.1
to use the following solution, you cannot use "select star"
you must itemize all the columns in both the SELECT list and the GROUP BY
, count(*) + 1 as Rank
from myTable as t
join myTable as m
on t.time < m.time
by Rank desc