Ask a Question related to Coldfusion Database Access, Design and Development.
-
adult.swim #1
comparing 2 tables 1 database
Im trying to compare the records of 2 different tables in the same database,
using cfif statement(s) and/or coldfusion or sql. If they're the same > output
results, if they're not the same > output different results, if field is emptyI've tried something along the lines of :> output another result.
<cfif form.mlsnumber EQ homes.mlsnumber>
form = table 1
homes = table 2
mlsnumber = a column thats in both tables being compared
adult.swim Guest
-
HELP! How can I get my tables (.FRM etc..) back into a database.
Hi, Can anybody tell me how I can get the backup ( just a file copy of the directory with .frm, .MYI and .MYD files) back into a newly created... -
Database is connecting but not seeing tables
I'm able to successfully connect to my Access database using the connection string "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" (for ASP.NET VB... -
Database Tables Not Showing
:confused; I am following the Tutorial for setting up the PHP/SQL GlobalCar Dynamic Page. Everything has gone fine until I got to Getting... -
Comparing two tables
Hi, I would have to make code in C++ that would check two database tables for differencies. The two tables should be identical. If there are any... -
Comparing rows in 2 tables
Jake wrote: Why? Why not use the solution you have in hand that works? Daniel Morgan -
paross1 #2
Re: comparing 2 tables 1 database
This kind of thing is usually done easily within a query, but you didn't provide enough information for us to help very much.
Phil
paross1 Guest
-
adult.swim #3
Re: comparing 2 tables 1 database
ok,
I made a form to get info from the user. I want to compare the info that the
user inputs with my database, if they match then i want to output the record
that matches the info input.
I had the form info input into an empty table, to compare the 2 tables, to
attempt to solve this problem.
So step by step, this is what I have so far:
1. formpage.cfm: user inputs fields matching the fields in my database
2. actionpage.cfm: form input goes into an empty table;
I call my databse in a query
and I'm trying to compare the 2 tables
using a cfif statement e.g. <cfif form.mlsnumber EQ homes mlsnumber>
then get output
If anyone has info let me know plz
adult.swim Guest
-
Kronin555 #4
Re: comparing 2 tables 1 database
There's no reason to put the user-entered data into a table just so you can
compare it.
actionpage.cfm:
<cfquery datasource="blah" name="checkForMatching">
select count(*) as numMatching from homes where misnumber = #FORM.misnumber#
</cfquery>
<cfif checkForMatching.numMatching gt 0>
Hey! you matched a value in the database!
<cfelse>
The value you entered isn't in the database
</cfif>
Kronin555 Guest
-
adult.swim #5
Re: comparing 2 tables 1 database
Dude,
Thank you so much, I've been beating my head against the wall trying to figure
out how to do this.
I have a follow up question:
<cfquery datasource="houses" name="checkForMatching">
SELECT *
FROM props
WHERE props.MLSnumber=#FORM.mlsnumber# OR
props.StreetNumber=#FORM.StreetNumber#
</cfquery>
I took the code u gave me and modified it, to try to include the other fields
in my form. But I get a syntax error when I run my actionpage. Do you c the
propblem with my code that I need to fix, or doies the 1st statement with the
mlsnumber have to pass 1st b4 the other fields in the form.
Is there a way I can write the WHERE clause so that the FORM fields get
checked indenpently, i.e. they can enter 1 field out of the 7 and get results.
adult.swim Guest
-
Dan Bracuk #6
Re: comparing 2 tables 1 database
If the datatype of props.streetnumber is char, you need single quotes in your
query.
Regarding having the query still give results even if some of the form fields
were not filled in, the answer is yes. You have to think your problem through
before you start coding so that you know how you want to handle fields with no
data. Bear in mind that what you get on your action page is dependent on the
type of form field.
The approach I prefer is to build a variable that becomes the where clause of
my query. Others prefer putting their logic code inside the cfquery tag. Both
methods work.
Dan Bracuk Guest
-



Reply With Quote

