Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple SQL?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am a beginner at SQL and Access and am having a problem viewing data from my database.

I am using an .asp file on my website to view information from a Access 2000 database. The database has two tables.

Table 1 (details) has a primary key called user.
Table 2 (notes) has a primary key called noteid.

The relationship is set with table 1 field 'user' being linked to 'user' in table 2.

I can view information fine on the website if I use:

sqltemp="select * from details where USER='"
sqltemp=sqltemp & myname & "'"
' myname is a variable gained from a text box on webpage

but if I try to include any details from Table 2 (notes) then I get an SQL error stating that ‘The specified field 'USER' could refer to more than one table listed in the FROM clause of your SQL statement’.

sqltemp="select * from details,notes where USER='"
sqltemp=sqltemp & myname & "'"
' myname is a variable gained from a text box on webpage

Any ideas on where I am going wrong?


 
Hi Mark,
You'll have to prefix the "user" with the table name, 'cause you now have two "user" fields in your query. Maybe like:

sqltemp="select details.* from details,notes where details.USER='"
sqltemp=sqltemp & myname & "'"

:) Gord
ghubbell@total.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top