Re: WHERE clause
| From: | Aron Pilhofer | Date: | Mon, 04 Mar 2002 14:04:29 +0000 |
| Subject: | Re: WHERE clause | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17445@lists.php.net to get a copy of this message | ||
MySQL is very well documented as well. www.mysql.com, click on
documentation.
"Dl Neil" <PHPml@DandE.HomeChoice.co.uk> wrote in message
news:160001c1c356$2f629c40$c200a8c0@jrbrown...
> 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
>