Jump to content
  • 0

Query_SQL Delete error.


_Dynosawr_

Question


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  69
  • Reputation:   10
  • Joined:  05/14/12
  • Last Seen:  

So I have an issue with the DELETE FROM syntax in Query_SQL.

Here's the script: http://pastebin.com/raw.php?i=ABv0KBWF

Hopefully once of you can figure out what's wrong with it ;o

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1131
  • Joined:  05/27/12
  • Last Seen:  

Remember that you only put single quotes (') around strings, not integers, so these parts need to be changed:

WHERE `id` = '"+.@f+"'"

Didn't look at the rest of it yet, but see if that fixes the problem.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  130
  • Reputation:   43
  • Joined:  12/11/11
  • Last Seen:  

You can actually have quotes (') around integers, it's not recommended but often easier if you don't know if you're using strings or integers. Often with dynamic content.

The delete statement in MySQL is

"DELETE FROM <table> WHERE <where condition>"

So you would not get (adding extra spaces for clarity)

"DELETE `" + .@b$[.@c] + "` FROM `" + .@g$ + "` WHERE `id` = ' " + .@f + " ' "

But rather (not totally sure what the variables are but I'm guessing .@b$ is the field)

"DELETE FROM `" + .@g$ + "` WHERE `" + .@b$[.@c] + "` = ' " + .@f + " ' "

Edited by plankt
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

You can use single-quotes around integers and the query will still work.

http://pastebin.com/raw.php?i=ABv0KBWF

query_sql("DELETE `"+.@b$[.@c]+"` FROM `"+.@g$+"` WHERE `id` = '"+.@f+"'");

In DELETE queries, you do not specify columns. Just "DELETE FROM" and it means delete the whole row.

query_sql("DELETE FROM `"+.@g$+"` WHERE `id` = '"+.@f+"'");

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  69
  • Reputation:   10
  • Joined:  05/14/12
  • Last Seen:  

Well if I can't delete the column then that rules out the delete data option x.x; Thanks for the help though guys.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Are you trying to clear a certain column?

You could use "UPDATE `table` SET `column`=0, `column2`='' WHERE ..."

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  69
  • Reputation:   10
  • Joined:  05/14/12
  • Last Seen:  

I'll try it ;P

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...