From: Peter Brawley Date: September 17 2005 9:59pm Subject: Re: Select ALL rows with WHERE statement List-Archive: http://lists.mysql.com/mysql/189215 Message-Id: <432C91CB.3070103@earthlink.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=======AVGMAIL-432C91CD5A27=======" --=======AVGMAIL-432C91CD5A27======= Content-Type: multipart/alternative; boundary=------------080007080809080604010608 --------------080007080809080604010608 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Alvaro, />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 >table. / You cannot send the query engine an "option". When the program determines that all rows are to be retrieved, you could set the WHERE clause to "WHERE 1=1", but why not simply have the program append no WHERE clause at all? PB ----- Alvaro Cobo wrote: >Hi all: > >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 table. > >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 fields. > >Very thankful in advance. > >Alvaro > >PD: System Details: Mysql server version 4.1.11, PHP 4.3.10-2, Debian Sarge. > > >------------------------------------------------------------------------ > >No virus found in this incoming message. >Checked by AVG Anti-Virus. >Version: 7.0.344 / Virus Database: 267.11.1/104 - Release Date: 9/16/2005 > > --------------080007080809080604010608 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Alvaro,

>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
>table.

You cannot send the query engine an "option". When the program determines that all rows are to be retrieved, you could set the WHERE clause to "WHERE 1=1", but why not simply have the program append no WHERE clause at all?

PB

-----

Alvaro Cobo wrote:
Hi all: 

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 table. 

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 fields.

Very thankful in advance. 

Alvaro

PD: System Details: Mysql server version 4.1.11, PHP 4.3.10-2, Debian Sarge. 
  

No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.1/104 - Release Date: 9/16/2005
--------------080007080809080604010608-- --=======AVGMAIL-432C91CD5A27======= Content-Type: text/plain; x-avg=cert; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-Description: "AVG certification" 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 --=======AVGMAIL-432C91CD5A27=======--