mysql queries
- JeremysFilms
-
JeremysFilms
- Member since: Feb. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 18
- Blank Slate
if i want to delete all rows where the value is equal to a bunch of things, would i be able to do something like:
DELETE FROM tbl WHERE bob='hi' OR 'hello' OR 'hey'
is there any way to do something like that? or do i need to do a query for each?
- Foxtrott
-
Foxtrott
- Member since: Aug. 16, 2006
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
You could do:
DELETE * FROM TABLE WHERE `thing`='something' AND `bla`='454'
and etc. You can use as many "AND" as you want.
- DFox
-
DFox
- Member since: Aug. 9, 2003
- Offline.
-
- Forum Stats
- Member
- Level 30
- Blank Slate
I think it would need to look like:
DELETE FROM tbl WHERE bob='hi' OR bob='hello' OR bob='hey'
If you have too many and don't feel like doing that, just throw them in an array and have a loop tack them on to the SQL statement.
- henke37
-
henke37
- Member since: Sep. 10, 2004
- Offline.
-
- Forum Stats
- Member
- Level 30
- Blank Slate
There is a shorter form:
where a in ('a','b','c')
Much less typing
Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.
- Rellizate
-
Rellizate
- Member since: Feb. 27, 2006
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
- Zendra
-
Zendra
- Member since: Sep. 7, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (13,663)
- Block
-
- Forum Stats
- Member
- Level 51
- Blank Slate
At 11/14/06 10:50 AM, Rellizate wrote:
'1' | `2`
Something is wrong with that part.
- Storm
-
Storm
- Member since: May. 19, 2006
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
At 11/14/06 10:50 AM, Rellizate wrote: DELETE FROM `bob` WHERE `1` = '1' | `2` = '2';
Isn't OR supposed to be || ?
- Rellizate
-
Rellizate
- Member since: Feb. 27, 2006
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
My mistake:
DELETE FROM `bob` WHERE `1` = '1' || `2` = '2';


