|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Multiple Field Search
I have the following query that checks for a total number of people based on 3 tables, with the first two tables always being joined together and then matching against another table sent from a form. The first two tables are always defined. This works great. But how could I do this if I wanted to send like 3 form values so that there are now 5 total tables or how many ever, but still matching against the two tables I have already established in (), being t1 and t2. So the other tables would come from form.list form.list1 form.list2 and so on. Any help? Thanks guys.
<cfquery name="crossmatch" datasource="datasource"> select count(*) as doctortotal from #form.list# t3, (select t1.FIRST_NAME, t1.LAST_NAME, t1.STATE from Verispan t1 union all select t2.FIRST_NAME, t2.LAST_NAME, t2.STATE from Accent t2 ) u where t3.FIRST_NAME = u.FIRST_NAME and t3.LAST_NAME = u.LAST_NAME and t3.STATE = u.STATE </cfquery> |
|
#2
|
|||
|
|||
|
Couldn't you do:
<cfquery name="crossmatch" datasource="datasource"> select count(*) as doctortotal from #form.list1# t3, #form.list2# t4, (select t1.FIRST_NAME, t1.LAST_NAME, t1.STATE from Verispan t1 union all select t2.FIRST_NAME, t2.LAST_NAME, t2.STATE from Accent t2 ) u where t3.FIRST_NAME = u.FIRST_NAME and t3.LAST_NAME = u.LAST_NAME and t3.STATE = u.STATE and t4.FIRST_NAME = u.FIRST_NAME and t4.LAST_NAME = u.LAST_NAME and t4.STATE = u.STATE </cfquery> etc...? Of course using form fields to determine the names of the tables used in the query has the potential to be a pretty large security concern...
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Quote:
Thanks for the response. Please explain a little more on the concern though, I am some what new to the security issues concerning queries and such. |
|
#4
|
|||
|
|||
|
Well, people could put in any table name in your database and that table would be used in the query, right? Now granted, in this case it would probably just fail if they tried to enter, say the name of a system table as the form field, because the join would fail if the table didn't have fields like firstname, lastname, etc. Still, in other cases it could cause much more trouble.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Multiple Field Search |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|