Is there a way to have two queries. One queries the result from a column into itself? In other words:
QUERY 1: Queries a 'registration' table that has the column 'userid'.
QUERY 2: Queries a 'users' table with the QUERY 1 result for 'userid' in order to result that particular user's information which was in the 'registration' table.
Make sense? If that is possible, what would it look like? Both queries will have multiple records result.
Query from Previous Query
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
that sure sounds like a join...
Code: Select all
SELECT b.* FROM table1 a INNER JOIN table2 b ON a.userid = b.useridCool. I began coding it when I realized the INNER JOIN was the way to go. But there is more to it than I thought. There is actually 3 tables involved. TABLE1 has the 'userid' for the query in TABLE2, but I need to show TABLE3 result which has the 'userlevel' query by TABLE2. In other words:
I call up TABLE1.
TABLE1 sends a field result to query TABLE2.
TABLE2 sends a field result to query TABLE3.
I echo TABLE3 result.
It is a bit strange to explain, but that is it. TABLE1 and TABLE3 do not have any common fields except through TABLE2. What about that?
I call up TABLE1.
TABLE1 sends a field result to query TABLE2.
TABLE2 sends a field result to query TABLE3.
I echo TABLE3 result.
It is a bit strange to explain, but that is it. TABLE1 and TABLE3 do not have any common fields except through TABLE2. What about that?
Like this?
Code: Select all
SELECT b.* FROM table1 a INNER JOIN table2 b ON a.userid = b.userid, table3 c ON b.id = c.idWill do. Thanks. http://www.postgresql.org was a BIG help.