Hello Monks,
I'm trying to find the best way to represent an SQL query using SQL::Abstract (actually SQL::Abstract::More via DBIx::DataModel; SQL::Abstract is also used by DBIx::Class). Unfortunately there is not a great deal of information on constructing SQL queries that fall outside the bounds of the usual 'SELECT * FROM x WHERE ...' using SQL::Abstract.
My ideal query:
SELECT CASE WHEN record.is_public = 'Yes' THEN 'public' WHEN EXISTS ( SELECT 1 FROM permissions WHERE permissions.rec_id = record.id AND user_id = $user_id ) THEN 'accessible' ELSE 'private' END AS viewable, record.id, record.display_name FROM record WHERE record.id = $rec_id; # or other criteria
...where $user_id and $rec_id (or other WHERE criteria) are supplied by the Perl code.
Has anyone used SQL::Abstract for this kind of query?
Thanks!
In reply to SQL::Abstract-ing subqueries by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |