Jump to content

[SOLVED] Array as a temporary table


wsantos

Recommended Posts

I'm trying to implement an array as a mysql temporary table.  Then do the join based on that array.

 

$qry="SELECT src,uid FROM table WHERE dst LIKE '$myFilter'";
$res=mysql_query($result);
while($row=mysql_fetch_array($res, MYSQL_ASSOC))
  $daTable[] = $row;

mysql_free_result($res);

$qry = "SELECT * from lookup_cid JOIN $daTable ON $daTable.uid = lookup_cid.uid";
$res=mysql_query($result);
while($row=mysql_fetch_array($res, MYSQL_ASSOC))
  $daTable2[] = $row;
mysql_free_result($res);

Link to comment
Share on other sites

Im trying to implement a subquery on php.  Here is my mysql query.

 

DROP TEMPORARY TABLE IF EXISTS tmpMain;
CREATE TEMPORARY TABLE tmpMain SELECT src,uid FROM table WHERE dst LIKE 'ABC';
DROP TEMPORARY TABLE IF EXISTS tmpCID;
CREATE TEMPORARY TABLE tmpCID SELECT cid FROM lookup_cid lcid JOIN tmpMain ON tmpCID.uid=lcid.uid;
DROP TEMPORARY TABLE IF EXISTS tmpCP;
CREATE TEMPORARY TABLE tmpCP SELECT app,appdata FROM table3 JOIN tmpCP ON tmpCP.cid=table3.cid;

<- SNIP ->
SELECT * from tmpFINAL;

 

The above query (replacing the names and removing a couple of filters and a couple more steps) works on mysql.  At the moment we are pulling reports using this manual subquery.  The reason we used temporary tables was based on the number of tables to be joined (7 to be exact) and number of records of the database.  However, it was noted on my previous post that

 

create temporary table ...

 

could not be implemented on php itself. Hence, I was thinking if it is possible to consider an array as a table that we can join with a mysql table.  Is there is any other way around this situation?  Thank you for pointing me in the right direction

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.