How to return multiple rows of data when only one unique variable is available for where clause?
P粉094351878
P粉094351878 2023-09-13 17:31:35
0
1
346

I currently have a very simple MySQL query that looks like this:

SET @recordID = 60749;
SELECT netID, ID, recordID, team
FROM NetLog
WHERE recordID = @recordID;

The variable recordID is unique for each row and is the only variable available to get the desired row.

But now I also need to return any other rows that have the same 'team' value as the original row. I tried several variations but it always returns "#1242 - Subquery returned more than 1 row".

SET @recordID = 60749;
SELECT a.netID, a.ID, a.recordID, a.team,
    (SELECT b.recordID FROM NetLog b WHERE b.team = a.team AND b.recordID <> a.recordID) as rID
FROM NetLog a
WHERE a.recordID = @recordID;

I would like to do this in one query if possible.

Can someone point me in the right direction?

P粉094351878
P粉094351878

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!