Re: Re: Another newbie question -- ANSWERED!!
| From: | John Holmes | Date: | Tue, 07 Sep 2004 17:35:20 +0000 |
| Subject: | Re: Re: Another newbie question -- ANSWERED!! | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-36096@lists.php.net to get a copy of this message | ||
From: "Pete Holsberg" <pjh@mccc.edu>
$sql = "SELECT * FROM $table "; $sql .= "WHEREThe single quotes around the search string are necessary to define the string. You can use double or single quotes, really, so long as you're making a string. Without the quotes, the database will think it's a column name.LastNameLIKE` '%$search_string%' "; $sql .= "ORFirstNameLIKE '%$search_string%' "; $sql .= "ORSpouseLIKE '%$search_string%' "; $sql .= "ORStreetLIKE '%$search_string%' "; $sql .= "OR
Also, should I have back tics around a column name EVERYWHERE it's used in a SELECT (in this case, following ORDER)?Backticks are not required anywhere, really, in this case. When they are required is when you have a column name that is either a reserved word or has special characters in it. If this is MySQL, it'll allow you to have column named called "order", "desc", "foo bar", etc, and not complain during the table creation. It will complain when it hits those reserved words in the queries, though, so that's why you use the backticks. ---John Holmes...