• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it possible to connect 2 select statements into one

 
john mattucci
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ELSE IF(@number = 2)
BEGIN
SELECT COUNT([outlet #])
FROM OM
WHERE [address] LIKE '%' + @address + '%';
SELECT [outlet #], [name], address, [city/town], [postal code], telephone
FROM OM
WHERE address LIKE '%' + @address + '%'
END
Would it be possible to obtain the # of records and records in one shot
Thank u for your time
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would want to use a sub query. I am not sure if what I am showing you will work, but it will be something similar to:
SELECT [outlet #], [name], address, [city/town], [postal code], telephone, (SELECT COUNT([outlet #]))
FROM OM
WHERE address LIKE '%' + @address + '%'
Hope that helps.
BTW - The query will be analized starting with the sub query, so it will do the COUNT first and then work it's way out.
[ September 02, 2002: Message edited by: Gregg Bolinger ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic