Andrew Tyrone wrote: >> >> INSERT INTO GROUPMEMBERS(USER_ID, GROUP_ID) >> SELECT '#Val(URL.USER_ID)#', GROUP_ID >> FROM GROUPS >> WHERE GROUP_ID IN (#ffGroups#) >> >> I don't get why it's not generating an error, though. >> '#Val(URL.USER_ID)#' does not exist in the GROUPS table. I >> tried making >> the following test query: >> >> <cfquery name="miketest"> >> SELECT '1', GROUP_ID >> FROM GROUPS >> </cfquery> >> >> and it threw an error, so I'm guessing because that SELECT statement >> replaces the VALUES portion of the INSERT statement, it lets >> it fly for >> some reason. Is this true? I was just curious... > > > In the first query, you're creating the values in the first column > dynamically, so it doesn't matter that the user_id is not in the groups > table. In the test query the only problem I can see is you don't have a > datasource defined. Both queries should work, even if your user_id is an > integer, although you shouldn't put single quotes around it if it is. > Whatever database you're using (I am assuming SQL Server), an implicit > conversion from char/varchar to int for the user_id column is happening > behind the scenes. > > Andy
Hey Andy, Sorry, yeah, I left off the DSN and when I put that in, it worked. So, I guess it's valid to just do: SELECT '1', '3', 'A', GROUP_ID FROM GROUPS even though the first three arguments of the select statement aren't even fields in the GROUPS table. I'm guessing if I were to dump the recordset of that select statement I would see 1, 3, and A repeated for every GROUP_ID that is returned, huh? It's almost like I'm building my own fields for the recordset instead of actually pulling the data from the table, except for the GROUP_ID? As far as the single quotes, I think I remember that I needed to use single quotes when using Oracle. I'm guessing double quotes are used for SQL? I will try dumping the output of the above select statement and see what it does. This is pretty interesting. Thanks! Mike ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:228748 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54