Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > ColdFusion

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-20-2010, 03:36 AM   PM User | #1
Hollywood
New to the CF scene

 
Join Date: Jan 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Hollywood is an unknown quantity at this point
problem from seletion from two tables!!

hi everyone i'm havin a problem with selecting data from two tables in a single database. i have a login page that looks like this
login.cfm

Code:
<cfform action="index.cfm" method="post">
<cfinput type="text" name="username">
<cfinput type="text" name="password">
<cfinput type="submit" name="submit">
</cfform>
and the index.cfm page looks like this
index.cfm
Code:
<cfquery name="qryrDe" datasource="mydsn>
	SELECT UserName, password, surName, middleName
     FROM Users, results
	WHERE UserName = <cfqueryparam value="#trim(form.Username)#" CFSQLType="CF_SQL_VARCHAR">
    AND password = <cfqueryparam value="#trim(form.password)#" CFSQLType="CF_SQL_VARCHAR">
  </cfquery>
it is always throwing an error that the username could be from any of the two tables. please any help will be highly appreciated. thanks
Hollywood is offline   Reply With Quote
Old 03-20-2010, 06:45 AM   PM User | #2
Gjslick
Regular Coder

 
Join Date: Feb 2009
Location: NJ, USA
Posts: 476
Thanks: 2
Thanked 70 Times in 69 Posts
Gjslick will become famous soon enough
Hey Hollywood. First, why do you need to select from two tables here? Is part of the data that you're looking for in one table, and another part in the other table?

If so, can you post the list of column names that are in each of the tables? That would help me in trying to figure out the query that you are trying to perform here.

-Greg
Gjslick is offline   Reply With Quote
Old 04-08-2010, 10:06 PM   PM User | #3
Jt107
New Coder

 
Join Date: Nov 2002
Posts: 29
Thanks: 1
Thanked 0 Times in 0 Posts
Jt107 is an unknown quantity at this point
I did not found any join when select from two tables.

Try this:

<cfquery name="qryrDe" datasource="mydsn>
SELECT UserName, password, surName, middleName
FROM Users u, results r
WHERE u.userid = r.userid
AND UserName = <cfqueryparam value="#trim(form.Username)#" CFSQLType="CF_SQL_VARCHAR">
AND password = <cfqueryparam value="#trim(form.password)#" CFSQLType="CF_SQL_VARCHAR">
</cfquery>
Jt107 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:26 PM.


Advertisement
Log in to turn off these ads.