General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 15th, 2003, 07:06 AM
3DGuy 3DGuy is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Somewhere...
Posts: 1 3DGuy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old November 15th, 2003, 05:49 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > trouble with WHERE clause


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT