Why does this SELECT have no OT?

<CFIF ListLen(SESSION.WHSurveyStruct.reasonString, ";") gt 0> <CFQUERY name="insertReasons" datasource="#REQUEST.dsn#"> INSERT INTO TWelcomeHome_Reason (ReasonID, SubReasonID, SurveyID) SELECT #sanitize(ListFirst(SESSION.WHSurveyStruct.reasonString, ";"))#, #sanitize(getLatestSurveyID.SurveyID)# <CFLOOP list="#sanitize(ListRest(SESSION.WHSurveyStruct.reasonString, ';'))#" index="thisReason" delimiters=";"> UNION ALL SELECT #sanitize(thisReason)#, #sanitize(getLatestSurveyID.SurveyID)# </CFLOOP> </CFQUERY> 

I'm trying to figure out what this does. I am confused with a loop, why not have a FROM expression? Well, they are just scalars.

How about choosing an operator outside the loop and one inside? I don’t seem to understand the meaning of union all . And how did it happen that three columns are indicated (ReasonID, SubReasonID, SurveyID), but in each value of select 2?

dropped:

structure

CACHED: false EXECUTIONTIME: 0 RECORDCOUNT: 8 SQL: INSERT INTO TWelcomeHome_Reason (ReasonID, SubReasonID, SurveyID) SELECT 6, 18, 245 UNION ALL
SELECT 6, 21, 245
UNION ALL
SELECT 6, 24, 245
UNION ALL
SELECT 3, 5, 245
UNION ALL
CHOOSE 3, 6, 245
UNION ALL
SELECT 3, 8, 245
UNION ALL
SELECT 3, 11, 245
UNION ALL
SELECT 3, 7, 245


+4
source share
2 answers

It looks like these are just SELECT scalar values, not records from any table. So

 INSERT INTO myTable SELECT 'foo' UNION ALL SELECT 'bar' 

will insert two entries in myTable, foo and bar .

+16
source

The short answer is that it does not select from the table. So there is no table for FROM from.

If you do:

 INSERT INTO TableSomething (ColumnA) SELECT 'A' UNION ALL SELECT 'B' 

He will embed A and B in ColumnA.

ColdFusion creates data for insertion, not for pulling from a table.

+7
source

All Articles