RE: Update Query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Aaron,

I'll tell you right now that I don't have ANY experience creating temporary
tables. None. Haven't needed to go down that road yet.

So, in the true spirit of the learning process, I'm going to do what anybody
else would (and should) do:

Take a wild guess. And here it is:

I think your process for creating your temporary table is flawed. I've
looked through the MySQL manual and found this:

"6.5.3 CREATE TABLE Syntax
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
[table_options] [select_statement]"

So, without a really good understanding of what you're trying to select into
the temporary table, your query might look like:

CREATE TEMPORARY TABLE $tbl_temp SELECT distinct(company_id) from
Associations where product_id=9;

Then you can do whatever query you need to against the temporary table then,
when you're done, you'll drop the temporary table.

Your MySQL error is probably occurring because there is no table on which to
perform the query you're sending to the database.

I'm positive there are others on this list with more experience using
temporary tables than I, but this might be a push in the right direction (I
hope).

Hope this helps.

Rich

> -----Original Message-----
> From: Aaron Bryer [mailto:aaron@web-sites.com]
> Sent: Wednesday, October 29, 2003 3:18 PM
> To: php-db@lists.php.net
> Subject: RE:  Update Query
> 
> 
> I did that below is the exact excerpt from the source of the 
> web browser
> 
> <!--insert into Temp (CompId) SELECT distinct(company_id) 
> from Associations
> where product_id=10-->
> 
> The My Sql Error is
> 
> Query failed : You have an error in your SQL syntax near '' at line 1
> 
> I have tried entering () around the select statement but that 
> seamed to make
> more errors
> 
> Thanks
> 
> Aaron
> 
> -----Original Message-----
> From: Hutchins, Richard [mailto:Richard.Hutchins@Getingeusa.com]
> Sent: Wednesday, October 29, 2003 3:07 PM
> To: 'aaron@web-sites.com'; php-db@lists.php.net
> Subject: RE:  Update Query
> 
> 
> How do you know it failed? What is the mysql_error() returning to you?
> 
> I'd also recommend you echo out the query to the browser window before
> sending it so you can see exactly what's being sent to the 
> database. That'll
> help you troubleshoot SQL problems on your own.
> 
> > -----Original Message-----
> > From: Aaron Bryer [mailto:aaron@web-sites.com]
> > Sent: Wednesday, October 29, 2003 3:02 PM
> > To: php-db@lists.php.net
> > Subject:  Update Query
> >
> >
> >
> > Hello, I ma new to the list and looking for some help with
> > the following
> > query.
> >
> > insert into Temp (CompId) SELECT distinct(company_id) from
> > Associations
> > where product_id=9;
> >
> > When I exe that statement directly on the mysql command line
> > It exe's with
> > no problem. However when I
> > exe that through php $result = mysql_query($query) or
> > die("Query failed : "
> > . mysql_error()); it fails every time.
> >
> > Any Ideas?
> >
> > Using MYSQL 3.23.54
> > PHP 4.1.2
> >
> >
> > Thanks
> >
> > Aaron
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux