MySql SELECT

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
Zerano
Posts: 10
Joined: 16 Jun 2011, 10:18

MySql SELECT

Post by Zerano »

Hello i have created 2 tabeles and set the relationship between them:
Image

and now i wont to get the data(name) from the character tabel based on the username.

but i do not know how to do the query for it. i have tried this:

Code: Select all

   PreparedStatement new_sql = conn.prepareStatement("SELECT * FROM user LEFT JOIN character ON user.iduser=character.iduser WHERE user.username=?");
            new_sql.setString(1, username);
            ResultSet new_result = new_sql.executeQuery();
            new_result.first();
            String name = (String) new_result.getString(0);
            trace(name);
but it doesn't work.

i hope you can help me.
Post Reply