The optimization is understandable but I'm not sure how much it would
affect it if you did the select outside the insert statment vs inside.
Either way you are selecting the same thing but I dont know which way is
better.
Well just playing around with it for a bit I think I found something.
The value from memory is a variable of some sort right? I dont know what
language you are using so I'm not sure what it will hold.
Anyways you could do something like the following:
INSERT INTO table1(col1, col2) SELECT table2.col1a, "variablehere" FROM
table2 WHERE [blah];

This will work becuase if you do a SELECT 5 you get 5 back. So if you do
it with SELECT variable(aka some literial) you will get the
variable(literial) back and you will have two cols to match your
table1(col1, col2).
HTH
-Nick

> Sorry...yes...both columns have a NOT NULL constraint which makes
> inserting a blank a problem. My only other option is to do the SELECT
> first, then push the result into the INSERT with the other memory only
> variable. I'm doing this for a system that will undergo high volumes,
> and want to do what I can to optimize the number of individual selects.
>
> I'm probably going to have to do the alternate technique regardless. =\
>
> On Tuesday, September 10, 2002, at 05:23  PM, Nicholas Stuart wrote:
>
>>> From my experince this is not possible.
>> Is there any reason why you can not simply do two inserts following
>> each
>> other?
>> INSERT INTO table1(column1) SELECT column1a FROM table2 WHERE
>> [something]
>> INSERT INTO table1(column2) VALUES(valueFromMemory)
>> (as if you didnt know that already)  =D
>> There should be no reason why you couldnt do this as there is nothing
>> that
>> ties the two columns together (that I can see here).
>> Maybe explain a bit more and we might be able to give you more info.
>>
>> -Nick
>>
>>> I have to do an insert and need to nest a select inside. I have tons
>>> of
>>> documentation on a very simple version of this, however my
>>> requirements
>>> are one step beyond that. Here is what I'd like to do in MySQL:
>>>
>>> insert into
>>>
>>> table1
>>>
>>> (column1, column2)
>>>
>>> values
>>> (select column1a from table2 where [something],
>>> valueFromMemory)
>>>
>>> If you'll notice, I want one column from a select and one column
>>> outside the select. Is this possible in MySQL? All the documentation
>>> I've read about MySQL says it can't be done.
>>>
>>> Thank you in advance!
>>>
>>> Mark
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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 <[EMAIL PROTECTED]>
>>> To unsubscribe, e-mail
>> <[EMAIL PROTECTED]>
>>> Trouble unsubscribing? Try:
>> http://lists.mysql.com/php/unsubscribe.php
>>>
>>
>>
>>
>



---------------------------------------------------------------------
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 <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to