PDA

View Full Version : delete and and


alaios
01-13-2005, 09:22 PM
Could u plz explain me why the delete with the the and doesn't work??
delete from sessions where session="f90272aa4c90197776c2d269c4e7f8d0" and isbn=" 0-0230942-1-4"

this command
delete from sessions where session="f90272aa4c90197776c2d269c4e7f8d0"
works fine
delete from sessions where isbn=" 0-0230942-1-4"
and also this one too

Scrowler
01-13-2005, 10:28 PM
from what i can see, there is no reason they shouldn't work together. but if you can't get it sorted, just do two queries. i also expect that you only want to delete one session? include limit attribute.


delete from sessions where session="f90272aa4c90197776c2d269c4e7f8d0" limit 1
delete from sessions where isbn=" 0-0230942-1-4"


personally, i would write the query's attribute names in uppercase, but that probably doesn't affect the script's operation, except your tablename, which is case sensitive, i.e. 'sessions' will work but 'SESSIONS' wont.


DELETE FROM sessions WHERE session = "f90272aa4c90197776c2d269c4e7f8d0" LIMIT 1
DELETE FROM sessions WHERE isbn = " 0-0230942-1-4"

raf
01-13-2005, 10:38 PM
doing it withtwo querys is impossible. That would be the equivalent of
where session="f90272aa4c90197776c2d269c4e7f8d0" OR isbn=" 0-0230942-1-4"

Could u plz explain me why the delete with the the and doesn't work??
What do you mean? Do you get an error or are no rows deleted?

If no rows or deleted, then this usually means that none of the records passed both conditions ... was the space in the isbn-value intentionally?
try a
SELECT COUNT(*) as checknum FROM sessions WHERE session="f90272aa4c90197776c2d269c4e7f8d0" and isbn=" 0-0230942-1-4"

and check if checksum is higer then 0