Gossamer Forum
Quote Reply
Hi, ive read the previous posts about the unique function and realize that it searches for unique rows and not a specific column. My problem is that i have a unique id which i need to display for each row but i only want to display some unique columns. IE:

TABLE: ID | name | state
1 john Alabama
2 john California
3 john Alabama

my $sth = $table->select ( { Name => $IN->param('Name') }, ['DISTINCT(Name)', 'ID', 'State'] );
this will result in all 3 rows returned cause they all have a unique ID. I just want rows 1 and 2 returned.

Any idea on how to solve this?

Also my form has many fields for this example lets use 2, name and state.
If the user wants to search for john in alabama ive tryed to create a string
my $str= "Name => $IN->param('Name'), State => $IN->param('State')";
my $sth = $table->select ( { $str }, ['DISTINCT(Name)', 'ID', 'State'] );

This does not work, any ideas on how to include multiple conditions?


Quote Reply
Re: [hagai] UNIQUE In reply to
Not sure whats not working (except the wrong field?)

I'm guessing you are trying to get a list of the "states" ?

my @list = $table->select ( ['DISTINCT(State)'], { Name => $IN->param('Name') } )->fetchrow_array;

...which should return an array ... so you can access it with;

print join "<BR>", @list;

...or, just a loop;

foreach (@list) {
print "$_ <BR>";

Hope that helps :)


Andy (mod)
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!