MySQL syntax error messages suck

Status
Not open for further replies.

topham

Ars Legatus Legionis
13,756
Subscriptor
Tiiba":1d2tk4gy said:
When MySQL has a syntax error, it says something like "syntax error near...". It tends to take me a friggin half an hour to find out I forgot a comma somewhere. is there a better way? :(

sure there's a better way, use something to validate the sql up front.
MySQL is brutal in many, many ways. It will bite you in the ass a dozen different ways.
 

wallinbl

Ars Legatus Legionis
14,324
Subscriptor
Blacken00100":2yodfdg1 said:
topham":2yodfdg1 said:
MySQL is brutal in many, many ways. It will bite you in the ass a dozen different ways.
^ optimist.
Yeah, but having the INSERT statement be able to use the UPDATE syntax is pretty cool. I'm not a fan of dealing with the column name list and value/parameter list being separate.
 
Tiiba":2k8isbd9 said:
When MySQL has a syntax error, it says something like "syntax error near...". It tends to take me a friggin half an hour to find out I forgot a comma somewhere. is there a better way? :(

HeidiSQL, because no one should ever have to use the MySQL console. And structure your queries.

Code:
SELECT tb1.column1, tb1.column2, 
       tb2.column1, tb2.column2, tb2.column3
FROM table1 AS tb1
LEFT JOIN table2 AS tb2
  ON tb1.column1 = tb2.column2
WHERE tb1.column1 = "something"
  AND tb2.column3 = "somethingelse"

Not only does it make larger queries easier to read, but you get the added bonus of being told what line your error is on. Rather than,
Code:
Syntax error on line one near "SELECT tb1.column1, tb1.column2, tb2.column1, tb2.column2, tb2.column3 FROM table1 AS  tb1 LEFT JOIN table2 AS tb2 ON tb1.column1 = tb2.column2 WHERE tb1.column1 = "something" AND tb2.column3 = "somethingelse"" Good luck, dipshit!

Okay, so MySQL doesn't actually call you names. But sometimes I feel like it does in the background.
 

fitten

Ars Legatus Legionis
55,635
Subscriptor++
wallinbl":3ghhpg5a said:
Blacken00100":3ghhpg5a said:
topham":3ghhpg5a said:
MySQL is brutal in many, many ways. It will bite you in the ass a dozen different ways.
^ optimist.
Yeah, but having the INSERT statement be able to use the UPDATE syntax is pretty cool. I'm not a fan of dealing with the column name list and value/parameter list being separate.

Yeah, but it's hardly unworkable.
 

wallinbl

Ars Legatus Legionis
14,324
Subscriptor
fitten":w39e7761 said:
wallinbl":w39e7761 said:
Blacken00100":w39e7761 said:
topham":w39e7761 said:
MySQL is brutal in many, many ways. It will bite you in the ass a dozen different ways.
^ optimist.
Yeah, but having the INSERT statement be able to use the UPDATE syntax is pretty cool. I'm not a fan of dealing with the column name list and value/parameter list being separate.

Yeah, but it's hardly unworkable.
Sure. I haven't used MySQL in years, but it was the one thing about it that I remember thinking should be in other SQL implementations. Probably a simple thing to implement as well.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
but you get the added bonus of being told what line your error is on

Really?!

If so that is monumentally idiotic. Their parser knows where in the query in terms of lines (and thus must have some concept of the character it is on) but doesn't just *give you the frikkin character* new lines mean nothing in pure SQL queries, they are just another form of white space?
 
Status
Not open for further replies.