Home > Net >  How to add to a INNER JOIN to pull multiple rows?
How to add to a INNER JOIN to pull multiple rows?

Time:11-26

I have the following SQL query:

select * from id i
inner join sval s 
on i.id = s.id 
where i.clid = 88 and s.fid = 996 and s.val = 'XLON'

At the moment, the above produces one row.

I want to expand this query so that I have s.fid = 997 and s.fid=998 as 2 additional rows. How would I do this?

CodePudding user response:

I think, the easiest way is to use an IN condition. So you can get results by a List of s.fids.

select * from id i 
inner join sval s on i.id = s.id 
where i.clid = 88 and s.val = 'XLON' and s.fid in (996, 997, 998)
  •  Tags:  
  • sql
  • Related