cfqury - the basic
First let?s us make an example table, here we make one contains some countries currency.
Example:
US Dollars
British Pounds
Euro
Australian Dollars
?
Give our table name: currency_table.
Then we setup the cfquery against our table.
The sql select statement will return everything from our table, starting on row one and go down to the last one.
|
< cfquery name="List_Currency" datasource="ds_name" username="username" password="password">SELECT * FROM currency_table </ cfquery> |
We then make the cfoutput query tag:
Remember to give it the same name as in the cfqury tag, List_Currency.
|
< cfoutput query="List_Currency">#currency# <br></ cfoutput> |
This will give the following output:
US Dollars
Hong Kong Dollars
Australian Dollars
British Pounds
Canadian Dollars
Danish Krona
Euro
Japanese Yen
Malaysian Ringitt
Swiss Francs
New Zealand Dollars
Norwegian Krona
Singapore Dollars
South African Rand
Swedish Krona
If we make a change in our cfquery, we can sort (order) the list.
|
< cfquery name="List_Currency" datasource="datasource" username="username" password="password">SELECT * FROM currency_table ORDER BY currency </ cfquery> |
This will give the following output:
Australian Dollars
British Pounds
Canadian Dollars
Danish Krona
Euro
Hong Kong Dollars
Japanese Yen
Malaysian Ringitt
New Zealand Dollars
Norwegian Krona
Singapore Dollars
South African Rand
Swedish Krona
Swiss Francs
US Dollars
Syntax
|
< cfquery name = "query_name" dataSource = "ds_name" dbType = "type" dbServer = "dbms" dbName = "database name" connectString = "connection string" username = "username" password = "password" maxRows = "number" blockFactor = "blocksize" timeout = "milliseconds" cachedAfter = "date" cachedWithin = "timespan" provider = "COMProvider" providerDSN = "datasource" debug>
SQL statements
</ cfquery> |
Advertisement
No User Comments.
No User Comments, be the first one to write your comments?


