mysql sub-select work around?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Mike Starke
Date:  
Subject: mysql sub-select work around?
/_> /_create temporary table tmp_idt
/_> /_SELECT (idt.unit * idt.price) AS Sub_Total
/_> /_FROM idt WHERE idt.myid = "1";
/_> /_
/_MySQL allows you to create a temp table and populate with the results of a select in one shot. That's what this
/_statement does. If the 'create temporary table' statement is immediately followed by a select statement, the results
/_of the select statement are populated into the the table using the columns names & data types returned from the select
/_statement.
/_

I had no idea it worked that way (populated if immediately followed by a select..).
I looked through the documentation on/at MySQL and could not find this info
documented anywhere.

/_As an aside, if the column idt.myid is an int datatype you don't need to quote it. If it's an integer and you quote
/_it, MySQL must do an implicit data type conversion, which may slow things down a bit. If the myid column is a varchar
/_data type then you must quote it.
/_

I didn't know that either...........many thanks for the tips today.

I suspect everything you pointed out above is MySQL specific isn't it. (?)
I have always made every effort to construct statements plain enough
as to be ported amongst rdbm's.

v/r
-Mike