Reputation: 109
I need to run a simple query on a table to find all the rows with a corresponding id. I then want to perform an inner join.
$applications = SELECT * FROM applications WHERE clubid = $_SESSION['id']
Once I have got all of the rows which meet this criteria, I then want to perform something along the lines of this. The $applications
is just someway of storing the rows that were found from the above query.
SELECT *
FROM $applications
INNER JOIN productsapplied
ON $applications.ID = productsapplied.appid;
Thanks for any help
Upvotes: 0
Views: 100
Reputation: 27
I think you can use Create View
CREATE VIEW applications AS
SELECT * FROM applications WHERE clubid = $_SESSION['id']
And quoting you
SELECT *
FROM applications
INNER JOIN productsapplied
ON applications.ID = productsapplied.appid;
Upvotes: 0
Reputation: 7668
You could combine both querys as
SELECT * FROM $applications
INNER JOIN productsapplied
ON $applications.ID = productsapplied.appid
WHERE $applications.clubid = $_SESSION['id']
Upvotes: 0
Reputation: 1269543
Do this all as one query:
SELECT *
FROM applications a INNER JOIN
productsapplied pa
ON a.ID = pa.appid
WHERE a.clubid = $_SESSION['id'];
Upvotes: 2