A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Advanced INSERT and SELECT queries?

  1. #1
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976

    Advanced INSERT and SELECT queries?

    I really cant wrap my head around how to write queries that use more then one table.

    What im trying to do is set up a account for a player. So when they register it set up in members table. Things like id, username, name, age and so on and then using that id insert into another game_table of their game profile. id, level, health, ...

    How do i write something like this in one query. Initially when they register all the values in the game_table will be their default values so i only need to create a row where the id = the id from the members_table and the rest of the values default.

    And when a user logs in i have a select query that searches the members table to see if the username and password feilds match but i also want to retrieve the values from the game_table for the same id.

    I have a rough idea of how it works but when i try writing it...

    So basically i want to select everything in the game_table where game.id = members.id only if members.username = $_post(username) and members.password = $_Post(password)

    Hope this makes sense

  2. #2
    associate admedia's Avatar
    Join Date
    Oct 2001
    Location
    is
    Posts
    1,347
    Look at JOIN statements.

  3. #3
    Network Guy
    Join Date
    Nov 2004
    Posts
    36
    Something like:

    Code:
    $uname = mysql_real_escape_string($_POST['username']);
    $passwd = mysql_real_escape_string($_POST['password']);
    $sql = "SELECT game_table.* FROM game_table INNER JOIN members ON members.id=game_table.id WHERE members.username='$uname' AND members.password='$passwd'";

  4. #4
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks for the replies guys. Helped out alot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center