Skip to content
Advertisement

Tag: if-statement

Selecting specified query from multiple select statement inside a single stored procedure

Good Day everyone! I’ve been searching everywhere on how to get a specified query using if-else statement inside a single stored procedure but still no luck on how to achieve those function. Here’s the T-Sql When exec command is called, it only return Command(s) completed successfully instead the value/table of the selected command. Since the @action is null, it should

If statement with select in Postgresql

I’ve having trouble to do a if with select, e.g: In SQL Server I can do this: But in postgresql I don’t have any idea how handle this. I’ve tring some ways to do this, but unfortunately I have not success. Answer The syntax for an IF in Postgres (or rather PL/pgSQL) is IF … THEN … END IF;, so

SQL If Not Any From Left Join Else Left Join

I the following query and I only want the results from the first left join that returns results for the addresses (add1/2/3). Is it possible, or should I just return it all and filer the results later? For example, if add1 returns 1 address, add2 returns 1 address and add3 returns 3 addresses, I only want the result set from

Postgres syntax error at or near “IF”

I am new to postgres and I am working on an assignment of mine. I had to create a table with only 1 column and, then I was given this statement to run in on pgadmin III: when I run this I get this error: syntax error at or near “IF” I have already take a look at this 38.6.2.

Advertisement