SELECT FROM Db

Josh Mellicker josh at dvcreators.net
Mon Aug 7 14:52:32 EDT 2006


Jim, I did not know about "[[" & "]]"

Brilliant! Thanks!

On Aug 1, 2006, at 6:34 PM, Jim Ault wrote:

> On 8/1/06 1:48 PM, "Josh Mellicker" <josh at dvcreators.net> wrote:
>> I like using "replace()"
>
> and yet some other readable ways for SQL
>   --that  "do-it-all-in-one-line"
>   --without using "replace"
>   -- only one function call, merge()
>   --   yet remain readable
>
> ------------------ one line  (watch word wrap)
>   put merge("DELETE FROM [[tmysqltableName]] Where [[tIDcolumnName]] =
> '[[tRecordID]]'") into theSQL
>
>   -------------------- or another way = same result (watch word wrap)
>   put merge("DELETE FROM [[tmysqltableName]] Where [[tIDcolumnName]] =
> '[[tRecordID]]'") \
>       into theSQL
>
>   -------------------- yet another way = same result
>   put merge("DELETE FROM [[tmysqltableName]] "  & \
>   "Where [[tIDcolumnName]] = '[[tRecordID]]'") \
>       into theSQL
>
>   -------------------- or another way to get a COMPLEX result
>   put tRecordID + 1 into tRecordID2
>
> put merge("" & \
>       "DELETE FROM [[tmysqltableName]] "& \
>       "Where ([[tIDcolumnName]] = '[[tRecordID]]' "& \
>       "OR  [[tIDcolumnName]] = '[[tRecordID-1]]') "& \
>       "AND  [[tIDcolumnName]] = '[[tRecordID2]]'" & \
>       "") into theSQL3
>
>
> Fun with Rev :-)
>
> Jim Ault
> Las Vegas
>
>
> On 8/1/06 1:48 PM, "Josh Mellicker" <josh at dvcreators.net> wrote:
>
>> I like using "replace()"
>>
>>
>> I find this very readable and simple to write:
>>
>>      put "DELETE FROM `tmySQLtableName` WHERE `tIDcolumnName` =
>> tRecordID" into theSQL
>>
>>
>> then, replacing the placeholders:
>>
>>      replace "tmySQLtableName" with "accounts" in theSQL
>>      replace "tIDcolumnName" with "accountID" in theSQL
>>      replace "tRecordID" with q(tRecordID) in theSQL
>>
>>
>>
>> here's the actual handler from whence I draw the example:
>>
>> ON jjSQLdelete tRecordID, tIDcolumnName, tmySQLtableName
>>      put "DELETE FROM `tmySQLtableName` WHERE `tIDcolumnName` =
>> tRecordID" into theSQL
>>      replace "tmySQLtableName" with tmySQLtableName in theSQL
>>      replace "tIDcolumnName" with tIDcolumnName in theSQL
>>      replace "tRecordID" with q(tRecordID) in theSQL
>>      doThisSQL theSQL
>> END jjSQLdelete
>>
>>
>> FUNCTION q a
>>      return quote & a & quote
>> END q
>>
>> FUNCTION bq a
>>      return "`" & a & "`"
>> END bq
>>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list