List:General Discussion« Previous MessageNext Message »
From:boris hajduk Date:November 18 2001 4:50am
Subject:Re[2]: many similar requests -> 1 request
View as plain text  
Sunday, November 18, 2001, 1:26:23 AM, Sergei wrote:

SG> Or you can emulate UNION with temporary table.
SG>   CREATE TEMPORARY xxx SELECT ...
SG>   INSERT xxx SELECT ...
SG>   SELECT xxx ...

I used this solution for a good reason : it seems cleaner than the
1..200 thing

:) Thank you so much !

for the record, here is the SQL request:

if ($sortby=="POS") {
 mysql_query("create temporary table POS_TEMP select iPosition as pos, iCDAid as cd_id
from cdaudio where iPosition!=0");
 mysql_query("insert into POS_TEMP (pos, cd_id) select iPosition2, iCDAid from cdaudio
where iPosition2!=0");
 mysql_query("insert into POS_TEMP (pos, cd_id) select iPosition3, iCDAid from cdaudio
where iPosition3!=0");
 mysql_query("insert into POS_TEMP (pos, cd_id) select iPosition4, iCDAid from cdaudio
where iPosition4!=0");
 mysql_query("insert into POS_TEMP (pos, cd_id) select iPosition5, iCDAid from cdaudio
where iPosition5!=0");
 $result=mysql_query("select cdaudio.iCDAId, user.vchEmail, cdaudio.vchCDATitle,
cdaudio.dtCDADate,
    cdaudio.vchComments, cdaudio.irating, user.vchFirstName, loan.iLoanId,
genre.vchGenreDesc,
    cdaudio.iRegion, cdaudio.vchCDAArtist, cdaudio.iNumberofCDs,cdaudio.iCopie,
user.iJukebox,
    cdaudio.iPosition, cdaudio.iPosition2, cdaudio.iPosition3, cdaudio.iPosition4,
cdaudio.iPosition5, pos
    from cdaudio
    left join loan on cdaudio.iCDAId = loan.iCDAId
    left join genre on cdaudio.iGenreID = genre.iGenreID
    left join user on cdaudio.iUserId = user.iUserId
    left join POS_TEMP on cdaudio.iCDAid=POS_TEMP.cd_id
    and user.iUserId = $userid
    order by pos");
}

Sergei, Bruce, thank you again for your help !

-- 
 Boris Hajduk                         bhajduk@stripped

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