List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:September 17 2005 9:59pm
Subject:Re: Select ALL rows with WHERE statement
View as plain text  
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
>  
>

Attachment: [text/html]
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
Thread
Select ALL rows with WHERE statementAlvaro Cobo17 Sep
  • Re: Select ALL rows with WHERE statementPooly17 Sep
  • Re: Select ALL rows with WHERE statementPeter Brawley17 Sep
  • Re: Select ALL rows with WHERE statementAlvaro Cobo18 Sep
    • Re: Select ALL rows with WHERE statementJasper Bryant-Greene18 Sep
      • Re: Select ALL rows with WHERE statementPooly18 Sep
    • Re: Select ALL rows with WHERE statementPeter Brawley18 Sep