0
mysql_query("SELECT a.guessNum FROM (SELECT * FROM PeerPrediction1 WHERE taskid=$taskid INNER JOIN UserData On username) a WHERE spanflag=0");

I have this query but it does not work. PeerPrediction1 is a table with schema: username, taskid... Userdata: username, guessNum,spanfalg I followed this link, but still something wrong, could anybody help? Nested select statement in SQL Server

Community
  • 1
  • 1
rockmerockme
  • 131
  • 3
  • 13

2 Answers2

1

The query syntax is not correct, and you do not need sub-query for this , you can just use the join to get the data as

select
u.guessNum from PeerPrediction1 a
join UserData u on u.username = a.username
where 
a.taskid = ? --- $taskid
and u.spanflag = 0 
Abhik Chakraborty
  • 42,961
  • 5
  • 46
  • 60
1

I think you miss-match inner join on username. See: http://www.w3schools.com/sql/sql_join_inner.asp

Fabio
  • 28
  • 2