Thanks Pooly and Peter:
The problem is that in the same php page I would like to choose either the
calculation from an especific year or the calculation from the whole table
I have a table which shows how much money somebody has spent each year and
there is the choice to know how much money they have spent from the begining
of the data input (fields: id, person, expenses, year).
I have built a dynamic page which shows a link with the years in the
database, and an aditional link which selects "all" records. So when people
chooses one of the year links, it sends an URL variable to the browser,
which is collected by the sql script to the WHERE statement and then it
filters the data and sum all the data from this specific year. But If they
choose the "all" link, the filter just disapears, and the sql query makes a
sum of the whole data.
I guess, once the years are fixed data, Poolys approach could be very
useful, because, I can configure the "all" link to send an URL variable with
the '%' wildcard, and the year links could still send their data (2005, for
example) which defines univocally each one of the records in the year field
in the budget table.
At the moment I was building two separate pages, so when people want the
infiltered data, the hyperlink directs then to another page, but it is much
better to have all the information in only one page, to make it easy the
Thanks a lot guys. It was a great help from you.
Very best regards,
PD: Sorry, but my English is not very good this time.
----- Original Message -----
From: "Pooly" <firstname.lastname@example.org>
Sent: Saturday, September 17, 2005 3:53 PM
Subject: Re: Select ALL rows with WHERE statement
2005/9/17, Alvaro Cobo <email@example.com>:
I've searched into the MySQL manual but I can't find the solution to this
very silly question.
I have a select query where I need to filter the data using the WHERE
statement. But also need to have an option to show all the data in the
For example (something like...):
SELECT * FROM `tbl_table1` WHERE field1 = 'Test' #To show all the rows
where field 1= 'Test'
But also have the choice to select all the rows using something like:
SELECT * FROM `tbl_table1` WHERE field1 = * or ALL or % #Select all the
You need to select all rows, but you have only control on the
condition on flied1, I am right ?
If you can input %, it should do the trick.
select * from table WHERE field1 like '%';
Why can't you do just
select * from table ??
Webzine Rock : http://www.w-fenec.org/
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://firstname.lastname@example.org