|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
trouble with WHERE clause
Ok.. I've been fiddling around with PHP and mySQL and I stumbled upon a problem... whenever I do an sql statement perhaps:
$result = mysql_query("SELECT * FROM table1 WHERE field2=$value"); As I have noticed in my situation, "field2" is not a PRIMARY KEY, so whenever I run the SQL statement it returns on an error... I have 2 fields, the first one is "id" which is auto_increment and a PRIMARY KEY. And the other one which is "field2" that is a TEXT. Now my question.. isn't there anyway to perform the WHERE clause into a non-primary key? |
|
#2
|
||||
|
||||
|
You can have any field in the WHERE statement. You just need to remember that strings need single quotes around the value, and numbers don't.
e.g. WHERE surname = 'foo' WHERE age = 15 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > trouble with WHERE clause |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|