0

I'm using this query:

SELECT split_part(full_path, '/', 4)::INT AS account_id,
       split_part(full_path, '/', 6)::INT AS note_id,
       split_part(full_path, '/', 9)::TEXT AS variation,
       st_size,
       segment_index,
       reverse(split_part(reverse(full_path), '/', 1)) as file_name,
       i.st_ino,
       full_path
FROM gorfs.inodes i
JOIN gorfs.inode_segments s
  ON i.st_ino = s.st_ino_target

As you can see, it returns me the 4th "word" as account_id.

split_part(full_path, '/', 4)::INT AS account_id,

I want to filter that, for example:

WHERE account_id = 14134

How can I do that?

  • 1
    Could you not do WHERE split_part(full_path, '/', 4)::INT = 14134? – joyleak Mar 8 '16 at 4:40
1

Use an outer query.

SELECT
 *
FROM (
  SELECT
    split_part(full_path, '/', 4)::INT AS account_id,
    ...
) AS whatever_label
WHERE account_id::integer = 14134;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy