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


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to