473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Request Query with three tables

229 100+
Hi, I wonder if there are any pointers to the following problem.

I Have three tables.

tbllogin
L.userid

tblprofile
P.userid,p.profileid,name,surname,etc

tblWatches
WatchingUserID,watchedprofileid

In each table these ids are the same
L.userid,P.userid,WatchingUserID

In the query below I collect all the watchedprofileid, being followed by WatchingUserID
watchedprofileid = p.profileid

Expand|Select|Wrap|Line Numbers
  1. lngprofileid=CLng(Request("UserID"))
  2. If lngprofileid <> "" And lngprofileid <> 0 Then
  3.  
  4. Set rs=Server.CreateObject("ADODB.Recordset")
  5. rs.CursorLocation = 3
  6. SQLQuery="Select L.accept, etc,etc,etc FROM tbllogin L INNER JOIN tblprofile P ON L.UserId = P.UserId "
  7.  
  8. SQLQuery= SQLQuery & " where 
  9. SQLQuery= SQLQuery & " p.ProfileID in (Select WatchedProfileID from tblWatches where WatchingUserID = 0"  & Clng(lngprofileid) & ")"
  10.  
  11. SQLQuery= SQLQuery & " order by L.latestvisit desc"
  12.  
It all works fine. The problem I have is I want to include in the title and description of the page, details about the userid from tblprofile such as their name, surname etc.

Unfortunately as the query is written no combination and playing around with the query will get that info.

I just wondered if there was a different way to achieve the same result plus info from tblprofile about the userid that is used in the query.
Any pointers would be a great help
Thanks in advance
Richard
Feb 23 '14 #1

✓ answered by Rabbit

I think I see what you mean now. In that case, you should just run a separate query to pull that data. Trying to incorporate that into one query just repeats a bunch of unnecessary data for every row.

4 1350
Rabbit
12,516 Expert Mod 8TB
I don't understand what you mean. You're joining to the tblprofile so you shouldn't have any issues getting fields from that table.
Feb 23 '14 #2
fran7
229 100+
Hi,
I have a user (no 1), he follows other users and I collect those he follows on a page. In the page all the right info is displayed, as you rightly said, from tblprofile that I want.

However, I want the title and description of the page to relate to the user (no 1). If I put " & Clng(lngprofileid) & " in the title I get (no 1)s userid, but if I include any more info about (no 1) from tblprofile it includes info from the first user displayed in the page and not the user who is in the querystring. Ie the user who is following all the users displayed in the page.

Sorry if I did not explain it well before. Thanks for any advice.
Richard
Feb 23 '14 #3
Rabbit
12,516 Expert Mod 8TB
I think I see what you mean now. In that case, you should just run a separate query to pull that data. Trying to incorporate that into one query just repeats a bunch of unnecessary data for every row.
Feb 23 '14 #4
fran7
229 100+
Thanks, that's what I thought but needed an expert to confirm.
Thanks again
Richard
Feb 24 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Emilio | last post by:
Hello everyone. I hope someone can help me with this. I have 3 columns called EMPLOYEE_TEST, TEST_QA and EMPLOYEE_TEST_ANSWER. The TEST_QA table contains the following: TEST_QA_ID |...
5
by: EMW | last post by:
Hi, I have an Oracle database with different tables of data. They all have one common field. I need to combine some fields from three tables. i.e. field1 and field2 from table1 field3 and...
0
by: WindAndWaves | last post by:
Hi Gurus Here is another question that I have been struggling with for over a year. Basically, I would like to allow users to enter data into three tables in at the same time. The reason it...
6
by: John | last post by:
Hi I have three tables with a common id with which they can be linked. I need to merge them in a way that the resultant table has all records from three tables. Below is what sort of result I am...
7
by: cov | last post by:
I have a php query where I'm attempting to pull data from 3 different tables between a php form and mysql db. I had hoped early on to use a unique identifier to help ensure referential integrity...
1
by: doc1355 | last post by:
I have a feeling that this is an easy question. However I'm a newbee and don't have any idea how to do this. I have three tables that stores my users information. Each user has a unique ID that is...
5
by: CindySue | last post by:
Hello, I'm so stuck and this seems like it should be so simple. I have three tables, called Auction Items, Party #1 and Party #2. A bidder number may appear in one, two or all three of them....
3
by: NigelBrown | last post by:
Hi All, I have written the below UNION QUERY (I know its wrong but trying to show what I want to achieve) I would like all three tables to convert to one - this is only a one off every day and the...
36
by: rajeevs | last post by:
I am trying to connect three tables in a crosstab query. Tbl-1 Field - Staff Tbl-2 Field - Document Tbl-3 Fields - Staff Document Viewed What I am trying is to get a crosstab query or Vb module...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.