MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Alexander Keremidarski Date:March 27 1999 11:32am
Subject:Re: Mysql/Perl Question?
View as plain text  
What exactly do you want to do?
As I can understand you wan to give user ability to choose 5 fileds from table
with 30 fields in any order.

Parsing parameters to SQL is very easy because SQL is plain text language.
You can use any method of string formatting depending on your habits and
language you use.
In perl you can use:

# $user_selection contains something like "field1, filed5, field2" and is
paresd to script as parameters.

$your_query = "select $user_selection from your_table";
$your_query = sprintf("select %s from your_table", $user_selection);

you can even extend this as follows:

$your_query = "select $user_selection from $user_selected_table where
$user_selected_filter limit $user_selected_limit";

and parse something like:

$user_selection = "fileld2, concat(field5, ' ', field3 ), (field10
+ field11)/10 as some_calc";
$user_selected_table = "your_table";
$user_selected_filter = "field1 like 'a% and filed10 > 865'";
$user_selected_limit = 20;

as a result your query wll become:

select fileld2, concat(field5, ' ', field3 ), (field10 + field11)/10 as
some_calc from your_table where ield1 like 'a% and filed10 > 865' limit 20

which will display first 20 rows from .... see above

The only limit is your imagination :)

Douglas Brantz wrote:

> Thanks, but no that is what I have already.  I would like the ability to
> give the user five drop down menus displaying all 30 fields from a database,
> allowing them to choose a field in each from the table in any order they
> choose and then have a page where this information is displayed in a tables
> beginning with  the headings of each field and then the search results from
> the five selected choices.  This would be very helpful in a large database
> when you only want certain info.
> I've built an inventory form for the college with over 30 fields and it
> works great, but I don't need to pull up all the data from each record all
> the time and I could write a static search, but I thought it would be fun to
> learn something new.  I guess I need to learn how to parse the value that
> the user chooses so that mysql can read the variable, but I'm a painter not
> a computer programmer.
> Can anyone help?

Mysql/Perl Question?Douglas Brantz26 Mar
  • Re: Mysql/Perl Question?Sasha Pachev26 Mar
Re: Mysql/Perl Question?Douglas Brantz26 Mar
  • Re: Mysql/Perl Question?Micheal Mc Evoy26 Mar
Re: Mysql/Perl Question?Alexander Keremidarski28 Mar