Nullsif ? PG 9.1

From: Patrick B <patrickbakerbr(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Nullsif ? PG 9.1
Date: 2017-04-09 08:18:41
Message-ID: CAJNY3isjsDZA93NGR_8k0jmNL9TsME_f_CpKH+nSBSMf5wtoUA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi guys,

I've got this select:
SELECT split_part(n.node_full_path::text, '/'::text, 8)::integer AS id,

However, not always I will get the 8th field, and because of that, i may
get no data somethings.

Example:
/filesuser/client/27801123/attachment/4510/main
/filesuser/client/1111/attachment/21314134/file/12312312312/small/photo.jpg

Note that, sometimes it only goes until the 7th splitted_part, not always i
will get the 8th.

How can I tell the select, if no 8th field is found, then returns null?

Thanks!
Patrick

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Patrick B 2017-04-09 08:31:10 Re: Nullsif ? PG 9.1
Previous Message Steve Petrie, P.Eng. 2017-04-09 03:31:52 TimeScaleDB -- Open Source Time Series Database Released (www.i-programmer.info);