-1

SQL

DELETE FROM sex s, users u WHERE s.id = 195 and u.id = s.uid and u.sessionCheck = 'd986a074c7549c566bfed1d4ad7ca491'

Error

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's, users u WHERE s.id = 195 and u.id = s.uid and u.sessionCheck = 'd986a074c7549' at line 1

So clearly the error is with the joins in the delete. But everything I have tried just won't work.

I am using Server version: 5.6.16 - MySQL Community Server (GPL)

Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291
  • This question was caused by a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. – Kermit Apr 28 '14 at 13:21
  • http://stackoverflow.com/questions/1980738/sql-delete-with-join-another-table-for-where-condition – Hituptony Apr 28 '14 at 13:22
  • Disagree @Kermit :) I think its quite a helpful search term, so googling returned me nothing on the problem. If I've had this problem then somebody else will as well. – Jamie Hutber Apr 28 '14 at 13:24
  • 2
    @JamieHutber You must be using Google wrong. I searched and it returned 102,000 results. – Kermit Apr 28 '14 at 14:32
  • 1
    @Kermit That's because Google doesn't with documentation... – Jamie Hutber Apr 28 '14 at 15:09
  • 1
    @JamieHutber you should restructure that sentence in a way that makes more sense. – Zane Apr 28 '14 at 16:40
  • @Zane ... maybe they were going for this ... `WITH Documentation AS (SELECT * FROM [teh].[Googlez]) SELECT * FROM Documentation;` – swasheck Apr 28 '14 at 16:46

3 Answers3

2
DELETE s /* forgot to mention from which table you like to delete from these 2 */
FROM sex s
join users u on u.id = s.uid 
WHERE s.id = 195
and u.sessionCheck = 'd986a074c7549c566bfed1d4ad7ca491'
juergen d
  • 201,996
  • 37
  • 293
  • 362
0
DELETE s.* FROM sex s,users u   WHERE u.id = s.uid AND s.id = 195 AND u.sessionCheck = 'd986a074c7549c566bfed1d4ad7ca491'
Sajad Karuthedath
  • 14,987
  • 4
  • 32
  • 49
0
DELETE FROM sex 
WHERE sex.id IN (SELECT id 
                 FROM users u
                 WHERE u.sessionCheck = 'd986a074c7549c566bfed1d4ad7ca491')

To delete from both tables

DELETE s.*,u.*
FROM sex s
inner join users u on u.id = s.uid 
WHERE s.id = 195
and u.sessionCheck = 'd986a074c7549c566bfed1d4ad7ca491'
Mudassir Hasan
  • 28,083
  • 20
  • 99
  • 133