Okay, so that's a bad example, I suppose, because one could do something like that this way:
Category.ID, Category.Name, Links.*
FROM
Links, CatLinks, Category
WHERE
Links.ID = CatLinks.LinkID
AND
CatLinks.CategoryID = Category.ID
AND
(
Category.ID IN (1,2,3)
OR
Category.FatherID IN (1,2,3)
)
AND
Category.ID != 4or if using SQL::Condition, something like:
'Category.ID', 'IN', \"(1,2,3)",
'Category.FatherID', 'IN', \"(1,2,3)",
'Category.ID', '!=', 4,
);
$table = GT::SQL->table('Links','CatLinks','Category');
@results = @{$table->select($condition,['Category.ID', 'Category.Name', 'Links.*'])->fetchall_hashref};But my previous question is still a valid one as you should still be able to do it with SQL::Sets::subtract somehow, it would just be a lot slower.
I just can't figure out what tpyes of parameters it is expecting:
#-------------------------------------------------------------------------------
# takes two sets, A and B, and subtracts B from A. results enter current set
#
my $self = shift;
my $key = shift or return;
my $seta = shift or return;
my $setb = shift or return;Are $seta, and $setb GT::SQL::Table objects, or are they other GT::SQL::Set objects?
They almost have to be other Sets, with $key being a primary key type of column in each set.
If so, then how does set A and B get filled with data to begin with so that they can be compared..?
Maybe I'm losing my place somewhere and the answer is some methods in the base class?
Thanks for any help which you are willing to provide.
-Steven
Code:
SELECT Category.ID, Category.Name, Links.*
FROM
Links, CatLinks, Category
WHERE
Links.ID = CatLinks.LinkID
AND
CatLinks.CategoryID = Category.ID
AND
(
Category.ID IN (1,2,3)
OR
Category.FatherID IN (1,2,3)
)
AND
Category.ID != 4
Code:
$condition = GT::SQL::Condition->new( 'Category.ID', 'IN', \"(1,2,3)",
'Category.FatherID', 'IN', \"(1,2,3)",
'Category.ID', '!=', 4,
);
$table = GT::SQL->table('Links','CatLinks','Category');
@results = @{$table->select($condition,['Category.ID', 'Category.Name', 'Links.*'])->fetchall_hashref};
I just can't figure out what tpyes of parameters it is expecting:
Code:
sub subtract { #-------------------------------------------------------------------------------
# takes two sets, A and B, and subtracts B from A. results enter current set
#
my $self = shift;
my $key = shift or return;
my $seta = shift or return;
my $setb = shift or return;
They almost have to be other Sets, with $key being a primary key type of column in each set.
If so, then how does set A and B get filled with data to begin with so that they can be compared..?
Maybe I'm losing my place somewhere and the answer is some methods in the base class?
Thanks for any help which you are willing to provide.
-Steven