SELECT FROM Db

Jim Ault JimAultWins at yahoo.com
Tue Aug 1 21:34:18 EDT 2006


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
> 





More information about the use-livecode mailing list