Alvaro, >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 >using URL. That needn't raise a problem, especially in PHP. If the user chooses a year, have the page construct the appropriate WHERE clause. If she chooses "all", have the page remove any WHERE clause from the SQL statement. PB ----- Alvaro Cobo wrote: 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 using URL.An example: 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 mainteinance. Thanks a lot guys. It was a great help from you. Very best regards, Alvaro. PD: Sorry, but my English is not very good this time. ----- Original Message ----- From: "Pooly" <[EMAIL PROTECTED]> To: <mysql@lists.mysql.com> Sent: Saturday, September 17, 2005 3:53 PM Subject: Re: Select ALL rows with WHERE statement 2005/9/17, Alvaro Cobo <[EMAIL PROTECTED]>:Hi all: I've searched into the MySQL manual but I can't find the solution to thisvery silly question.I have a select query where I need to filter the data using the WHEREstatement. But also need to have an option to show all the data in the table.For example (something like...): SELECT * FROM `tbl_table1` WHERE field1 = 'Test' #To show all the rowswhere 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 thefields.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 ?? -- Pooly Webzine Rock : http://www.w-fenec.org/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] |
No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.1/104 - Release Date: 9/16/2005
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]