Subject changing "join" for "left join" inside a stored procedure
Author Sergio H. Gonzalez
Hello, is there any way to change some part of a select sentence inside a stored
procedure depending on a parameter?

This is what I need: I have a SP which should return all records or just the
selected records (I select records saving the IDs in a temp table). So I'd like
to change:

select * from customers join sel on sel.id = customers.id

for

select * from customers left join sel on sel.id = customers.id


depending on a parameter I send to the SP. The actual select is bigger than the
example. That's why I'm trying to avoid to write the sentence twice inside an if
statement.

Thanks!!

s