http://codex.wordpress.org/Class_Reference/wpdb
query
returns the number of affected rows. Instead use get_results
, which returns all the rows specified by the query. You can use the second parameter to specify how these results will be returned, either as objects or as an array etc
When dealing with sql, you should deal only with wpdb, there is very very rarely ever a reason to deal with the mysql_
prefixed php functions, as the WordPress’ database API does all of that.