2013-02-09 74 views
-2

我應該在哪裏放置WHERE子句。我應該在哪裏放置WHERE子句

$sql=("SELECT * FROM students LIMIT $startResults, $resultsPerPage"); 
+0

你有沒有想過閱讀MySQL手冊上'選擇'聲明? – 2013-02-09 04:39:26

+2

或者,您知道,使用Google? – 2013-02-09 04:42:15

回答

0

嘗試,

$sql=("SELECT * FROM students WHERE <where_condition> LIMIT $startResults, $resultsPerPage"); 
1

應該是這樣的:

$sql=("SELECT * FROM students WHERE (condition) LIMIT $startResults, $resultsPerPage"); 
1

...您的問題是一種模糊的,但....

通常人們做出查詢單個字符串,如果我猜你正在問什麼:

$sql="SELECT * FROM students WHERE `mysql_field`='$somevalue' LIMIT $number_of_results_you_want_returned"; 

記住上面的查詢並不妨礙對SQL injextion攻擊裸...

1
SELECT * FROM students WHERE character='willing to learn' AND Age < 35 LIMIT $startResults, $resultsPerPage 

WHERE和(如有必要)插入AND