Re: WHERE clause

From: Date: Mon, 04 Mar 2002 08:20:55 +0000
Subject: Re: WHERE clause
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-17441@lists.php.net to get a copy of this message
Jennifer, > Wondering do I have to have the WHERE clause in a select query? > $b=mysql_query( SELECT * FROM my_table) <-----can I use something like this > or do I have to put WHERE in the statement? Hate to answer a question with a question, but what happened when you tried typing this query into the MySQL client? (a far faster solution than waiting for someone on the list to get back to you!) RTFM: 6.4.1 SELECT Syntax SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT] [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS] [HIGH_PRIORITY] [DISTINCT | DISTINCTROW | ALL] select_expression,... [INTO {OUTFILE | DUMPFILE} 'file_name' export_options] [FROM table_references [WHERE where_definition] [GROUP BY {unsigned_integer | col_name | formula} [ASC | DESC], ...] [HAVING where_definition] [ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] ,...] [LIMIT [offset,] rows] [PROCEDURE procedure_name] [FOR UPDATE | LOCK IN SHARE MODE]] When you read these 'template' commands in the manual, if the word/clause/construct is enclosed in square brackets, eg [WHERE where_definition] then it is optional. Thus the minimalist SELECT statement looks like: SELECT select_expression,... which will only work with some scalar expression, eg SELECT 2+2; or SELECT month( '2002-03-04' ); so the minimum to work with a table is: SELECT select_expression,... FROM table_references and you're bang on the money! Regards, =dn

« previous php.db (#17441) next »