Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Old 09-08-2005, 10:22 AM SQL question
Novice Talker

Posts: 10
Trades: 0
I am not a SQL pro and I deleted all the uses to a forum that I run.

I used the following SQL statement intending to delete user_id 7 and 12.

DELETE FROM `phpbb_users` WHERE `user_id` = '7' or '12'

Instead it deleted all the user_id's! What is wrong with my statement?

Bruce
wappmanb is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-08-2005, 10:31 AM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
We need to analyze your 'WHERE' clause peice by peice

what you're telling the database is this:

Look at each row in the tabe,
if user_id = 7 is true then delete it
or, if 12 is true then delete it.

since any non zero number will always evaluate to true, every row gets deleted.

You need to change your query to look like this :
Code:
DELETE FROM `phpbb_users` 
WHERE `user_id` = '7' 
   OR `user_id` = '12'
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 09-09-2005, 11:04 AM
Novice Talker

Posts: 10
Trades: 0
Thanks!
wappmanb is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to SQL question
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31586 seconds with 12 queries