If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > delete / select by primary key

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-03-05, 18:04
localhost localhost is offline
Registered User
 
Join Date: Sep 2003
Posts: 13
delete / select by primary key

i have a table 'news' and i am trying to delete a row from it using something like this :

delete from news where index="12"

when i run that it gives me a syntax error at the index= section.

if i do select * from news where index="12" it does the exact same error.

my table looks like this :

+--------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+----------------+
| index | int(11) | | PRI | NULL | auto_increment |
| author | varchar(50) | YES | | NULL | |
| title | varchar(100) | YES | | NULL | |
| data | text | YES | | NULL | |
| date | date | YES | | NULL | |
+--------+--------------+------+-----+---------+----------------+

and if i select * from news, the row with index 12 is:

| 12 | test | testing | testing | 2005-01-03 |


any ideas? i can select/delete based on other values just not index. is it maybe the fact that i named it index?
Reply With Quote
  #2 (permalink)  
Old 01-03-05, 18:06
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
it's a numeric column, right?

try the query without the quotes around the 12

yes, index is a reserved word, so try it with backticks around the name

... where `index` = 12
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-03-05, 18:08
localhost localhost is offline
Registered User
 
Join Date: Sep 2003
Posts: 13
yeah i tried it with/without quotes with no luck, but putting the `'s around it worked. thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On