List:General Discussion« Previous MessageNext Message »
From:Bruce Ferrell Date:November 17 2001 9:08pm
Subject:Re: many similar requests -> 1 request
View as plain text  
How about a query something like this:

SELECT position, title FROM WHERE position1 IN (1...200) OR position2 IN
(1...200);

Caviats:

1.) I don't do this everyday so that query syntax could be all wet
(probably is in fact).  You may have to programaticly generate the IN
clauses to make it work.  I don't think elipses are supported.
2.) I may have misunderstood the result set you're trying for.

In anycase, I think you can get ther general idea of what I have in
mind.

boris hajduk wrote:
> 
> hi fellow mysql users :)
> 
> i'm programming a little application, and i do the following :
> 
> for ($i=0 ; $i<200 ; $i++)
> {
>   $result=mysql_query("select $i, title from book where position1=$i \
>                        or position2=$i"); // this query returns only 1 row
>   $row=mysql_fetch_row($result);
>   print("position: $row[0]  --   title: $row[1]  \n");
> }
> 
> this generates 200 sql queries... :/
> 
> do you see a way to make 1 sql query that would return my 200 rows ?
> 
> maybe something like :
> select "(increment j 0 -> 200)" , title from book where position1=j \
>   or position2=j;
> 
> note: given a number between 0 and 199, the number is stored in
> position1 OR position2 , but never both.
> 
> any idea ?
> 
> --
>  Boris Hajduk                   bhajduk@stripped
> 
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
> 
> To request this thread, e-mail <mysql-thread91588@stripped>
> To unsubscribe, e-mail
> <mysql-unsubscribe-bferrell=baywinds.org@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Thread
many similar requests -> 1 requestboris hajduk17 Nov
  • Re: many similar requests -> 1 requestBruce Ferrell17 Nov
    • Re: many similar requests -> 1 requestboris hajduk17 Nov
      • Re: many similar requests -> 1 requestSergei Golubchik17 Nov
        • Re: many similar requests -> 1 requestSergei Golubchik17 Nov
          • Re: many similar requests -> 1 requestboris hajduk18 Nov
            • Re: many similar requests -> 1 requestSergei Golubchik18 Nov
              • Re[2]: many similar requests -> 1 requestboris hajduk18 Nov
Re: many similar requests -> 1 requestAnvar Hussain K.M.19 Nov