Gossamer Forum
Home : Products : Gossamer Links : Discussions :

SELECT FROM with IN

Quote Reply
SELECT FROM with IN
my $variable = "12,23,34";
my $variable = "'12','23','34'";
my $variable = "['12','23','34']";
my $variable = "(12,23,34)";
my $variable = "('12','23','34')";

I tried all of them for that:

my $all_db = $DB->table('Links');

$all_db->select_options ("ORDER BY Contact_Name", "");

my $sth = $all_db->select ( ['ID','Title','aLogo','Contact_Name','Hits'],
GT::SQL::Condition->new (
ID => IN => $variable
) );
while (my ($id,$title,$logo,$name,$hits) = $sth->fetchrow_array) {
...

I stuck with passing IDs to this SQL. Anyone here with help, please?
Quote Reply
Re: [Robert] SELECT FROM with IN In reply to
Ok. I have forgotten to watch GTīs Code.
I just use an array to pass. :)
Quote Reply
Re: [Robert] SELECT FROM with IN In reply to
ID => IN => /@variable
Quote Reply
Re: [Robert] SELECT FROM with IN In reply to
Yup, or:

Code:
GT::SQL::Condition->new("ID","IN",\@variable)

BTW, make sure you use \ and not / as in your example Whistle

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!