Skip to content

allbut

rel.allbut([:a, :b, ...])

Remove some attributes from a relation (this might cause some tuples to become duplicates of others and thus be removed).

Example: What are the different T-shirt variants we stock, if we disregard colors?

Identical to project except that it keeps all attributes except those specified in the argument.

The specified attributes must be part of the input relation’s heading.

Consult the Overview page for the data model used in this example.

suppliers.allbut([:city]).to_a
=>
[{:sid=>"S1", :name=>"Smith", :status=>20},
{:sid=>"S2", :name=>"Jones", :status=>10},
{:sid=>"S3", :name=>"Blake", :status=>30},
{:sid=>"S4", :name=>"Clark", :status=>20},
{:sid=>"S5", :name=>"Adams", :status=>30}]
SELECT DISTINCT `t1`.`sid`, `t1`.`name`, `t1`.`status`
FROM `suppliers` AS 't1'