469,331 Members | 4,121 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,331 developers. It's quick & easy.

using INTERSECT/JOIN on same table in a loop

I am doing the following query using intersect but gives me an error
'error in sql syntax. I tried using join as well but gives me
similar error. In the following code still has intersect just to show
exactly what I want to do. My query in mysql console is working
without using intersect or join.

$query_objects = "";

for ($i=0; $i<$num_questions; $i++) {
if ($i != 0)
$query_objects = " intersect ";
$query_objects = $query_objects .
"select distinct obj from answer where qid=" .
$asked_questions[$i] .
" and ans=" . $asked_answers[$i];

}
Jul 20 '05 #1
1 2938
sunaina wrote:
I am doing the following query using intersect but gives me an error
'error in sql syntax. I tried using join as well but gives me
similar error. In the following code still has intersect just to show
exactly what I want to do. My query in mysql console is working
without using intersect or join.


Print the final string you have built, after the loop is done. Syntax
errors are often more apparent when you look at the actual string, not
the code that produces it.

Bill K.
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Nick | last post: by
2 posts views Thread by Elizabeth Harmon | last post: by
1 post views Thread by kadhir34 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.