Reputation: 129
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
Upvotes: 0
Views: 338
Reputation: 28
I think you miss-match inner join on username
. See: http://www.w3schools.com/sql/sql_join_inner.asp
Upvotes: 1
Reputation: 44844
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
Upvotes: 1