#Sql Syntax error

1 messages · Page 1 of 1 (latest)

tiny tangle
#

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''players' WHERE 'name' = 'IkeVoodoo'' at line 1

SELECT * FROM players WHERE name = 'IkeVoodoo'

crimson light
#

What's your table setup like?

#

and is "name" the id variable in your table?

tiny tangle
#

no, name is just a column

#

there is name and uuid (testing stuff)

#

And the best part is, that I am not even using MariaDB

umbral flax
#

u sure ur not using mariadb?

crimson light
#

are you missing a ;

tiny tangle
crimson light
#

SELECT * FROM players WHERE name='IkeVoodoo';

tiny tangle
#

I have MySQL running

tiny tangle
crimson light
#

lol

tiny tangle
#

Still errors

#

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''players'' at line 1

crimson light
#

try 'players'

tiny tangle
#

just using SELECT * FROM ? WHERE ? = ?; and using setString

#

*It's not taking external input, dw

umbral flax
#

u cant use ? for columns

random chasm
#

Can you even bind a table name?

tiny tangle
umbral flax
#

SELECT * FROM players WHERE ? = ?;

#

yes

tiny tangle
#

wait

#

LMAO

crimson light
#

WHERE only works for the ID column

tiny tangle
#

wait

#

what

#

Hol' up I am confused

umbral flax
#

SELECT * FROM players WHERE name = ?;

#

that's how u should use it

tiny tangle
#
var statement = conn.prepareStatement("SELECT * FROM ? WHERE ? = ?;");
statement.setString(1, name);
statement.setString(2, column);
statement.setString(3, value);
umbral flax
#

no

tiny tangle
#

I tried also doing what you said

#

It didn't work

umbral flax
tiny tangle
#

(as in: same error)

umbral flax
#

the above wont

crimson light
tiny tangle
# umbral flax `SELECT * FROM players WHERE name = ?;`
var sql = "SELECT * FROM %s WHERE %s = ?;".formatted(name, where);
var statement = conn.prepareStatement(sql);
statement.setString(1, String.valueOf(where.getValue()));

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''players'' at line 1

umbral flax
#

print sql

#

let's see what it looks like

tiny tangle
#

it just decided to crash somewhere else for some reason

#

So it's fixed now